Hologres MCP Server: Metadata, Query and Analysis
Connect to an MCP server to retrieve Hologres table metadata, run queries and analyze data for faster insights and efficient data management.
npx -y @aliyun/alibabacloud-hologres-mcp-serverOverview
Hologres MCP Server is an MCP (Model Context Protocol) adapter that exposes Hologres databases to AI agents and developer tools. It provides a consistent interface for discovering schema metadata, running SQL (SELECT/DML/DDL), collecting table statistics, and obtaining query and execution plans. By acting as the bridge between an AI agent and Hologres, the server enables programmatic inspection and analysis of data for rapid insights and automated data-management workflows.
This server is useful when you want AI assistants to reason about your Hologres data — for example, to suggest query optimizations, diagnose slow queries, or generate summaries based on table contents — while keeping credentials and logic centralized. It can be run from source, installed as a Python package, and integrated into MCP-enabled clients (uv/uvx or tools like Claude Code).
Features
- Connects AI agents to Hologres for metadata discovery and SQL execution
- Execute SELECT (including serverless), DML and DDL statements
- Retrieve query and execution plans for performance analysis
- Collect and surface table statistics for query optimization
- Built-in resource templates to fetch schemas, table lists, DDL, partitions and stats
- Prompts and helper tools to generate analysis/optimization guidance
- Integration options: local repository, pip package, or uv/uvx runner
Installation / Configuration
Clone the repository:
Install from PyPI:
Environment variables required by the server:
- HOLOGRES_HOST — Hologres host
- HOLOGRES_PORT — Hologres port (numeric)
- HOLOGRES_USER — access id / username
- HOLOGRES_PASSWORD — access key / password
- HOLOGRES_DATABASE — target database name
Example MCP client configuration (local directory mode, uv runner):
Example MCP client configuration (pip package, uvx runner):
Add to Claude Code (example):
Available Tools
Key tools exposed by the MCP server (name, purpose, primary parameters):
| Tool name | Purpose | Parameters |
|---|---|---|
| execute_hg_select_sql | Run a SELECT query | sql (string), limit, timeout |
| execute_hg_select_sql_with_serverless | SELECT using serverless compute | sql (string), resource hints |
| execute_hg_dml_sql | Execute DML (INSERT/UPDATE/DELETE) | sql (string) |
| execute_hg_ddl_sql | Execute DDL (CREATE/ALTER/DROP/COMMENT) | sql (string) |
| get_hg_query_plan | Retrieve planner’s query plan | sql (string) |
| get_hg_execution_plan | Retrieve the execution plan | sql (string) |
| gather_hg_table_statistics | Collect/refresh table stats | schema_name (string), table (string) |
| call_hg_procedure | Invoke a stored procedure | proc_name, arguments |
| create_hg_maxcompute_foreign_table | Create MaxCompute foreign table | schema/table definitions |
Metadata helpers (for agents that don’t use resources):
| Tool name | Purpose | Parameters |
|---|---|---|
| list_hg_schemas | List non-system schemas | — |
| list_hg_tables_in_a_schema | List tables in a schema with types | schema_name (string) |
| show_hg_table_ddl | Show a table/view/external-table DDL | schema_name, table |
Available Resources
Resource endpoints and templates provided by the server:
- Built-in: hologres:///schemas — get schema list
- Templates:
- hologres:///{schema}/tables — list tables in a schema
- hologres:///{schema}/{table}/ddl — get table DDL
- hologres:///{schema}/{table}/statistic — get collected stats
- hologres:///{schema}/{table}/partitions — list partitions (partitioned tables)
- System paths (system:///…):
- hg_instance_version, guc_value/<guc_name>
- missing_stats_tables, stat_activity
- query_log/latest/
, query_log/user/ / , query_log/failed/ / Use Cases
- Inspect schema and table structure before building queries:
- Use list_hg_schemas → list_hg_tables_in_a_schema → show_hg_table_ddl to programmatically construct safe queries.
- Run and debug queries:
- execute_hg_select_sql to fetch results for analysis; get_hg_query_plan and get_hg_execution_plan to diagnose slow queries and suggest optimizations.
- Automated performance tuning:
- gather_hg_table_statistics to refresh statistics, then re-run planner to compare improved plans.
- Data management and DDL automation:
- execute_hg_ddl_sql to create/alter tables or create_hg_maxcompute_foreign_table to integrate MaxCompute datasets.
- Integrating with AI assistants:
- Expose these tools to an AI agent (via MCP) so it can answer natural language questions about your data, propose query improvements, or generate summaries.
Testing and Reliability
The project includes unit and integration tests. Unit tests use mocked dependencies and cover SQL validation, tool behaviors and resource handling. This improves confidence before deploying the MCP server in production environments.
For the source, examples, and full reference, see the repository on GitHub:
- Inspect schema and table structure before building queries: