AnalyticDB PostgreSQL MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
AnalyticDB PostgreSQL MCP Server serves as a universal interface between AI Agents and AnalyticDB PostgreSQL databases. It enables seamless communication between AI Agents and AnalyticDB PostgreSQL, helping AI Agents retrieve database metadata and execute SQL operations.
Installation
You can set up the server either from the source code for development or by installing it from PyPI for direct use.
Option 1: From Source (for Development)
This method is recommended if you want to modify or contribute to the server.
Option 2: From PyPI (for Production/Usage)
This is the simplest way to install the server for direct use within your projects.
Running the Server
The server can be run in two transport modes: stdio (default) for integration with MCP clients, and http for direct API access or debugging.
Make sure you have set up the required Environment Variables before running the server.
Stdio Mode (Default)
This is the standard mode for communication with an MCP client.
Streamable-HTTP Mode
This mode exposes an HTTP server, which is useful for testing, debugging, or direct integration via REST APIs.
> **Security:** When binding to 0.0.0.0 or any network-accessible address, always set an authentication token via --auth-token or the MCP_AUTH_TOKEN environment variable. Without a token, the /mcp endpoint is open to unauthenticated access. Clients must include the Authorization: Bearer header in all requests.
MCP Integration
To integrate this server with a parent MCP client, add the following configuration to the client's configuration file. The arguments in the args array will depend on the transport protocol you choose.
Example for Stdio Transport
> **Note:** Since stdio is the default, you can optionally omit "--transport", "stdio" from the args array.
Example for Streamable-HTTP Transport
Tools
* execute_select_sql: Execute SELECT SQL queries on the AnalyticDB PostgreSQL server
* execute_dml_sql: Execute DML (INSERT, UPDATE, DELETE) SQL queries on the AnalyticDB PostgreSQL server
* execute_ddl_sql: Execute DDL (CREATE, ALTER, DROP) SQL queries on the AnalyticDB PostgreSQL server
* analyze_table: Collect table statistics
* explain_query: Get query execution plan
* adbpg_graphrag_upload
- **Description:** Upload a text file (with its name) and file content to graphrag to generate a knowledge graph.
- **Parameters:**
- filename (text): The name of the file to be uploaded.
- context (text): The textual content of the file.
* adbpg_graphrag_query
- **Description:** Query the graphrag using the specified query string and mode。
- **Parameters:**
- query_str (text): the query content.
- query_mode (text): The query mode, choose from [bypass, naive, local, global, hybrid, mix]. If null, defaults to mix.
* adbpg_graphrag.upload_decision_tree(context text, root_node text)
- **Description:** Upload a decision tree with the specified root_node. If the root_node does not exist, a new decision tree will be created.
- **Parameters:**
- context (text): The textual representation of the decision tree.
- root_node (text): The content of the root node.
* adbpg_graphrag.append_decision_tree(context text, root_node_id text)
- **Description:** Append a subtree to an existing decision tree at the node specified by root_node_id.
- **Parameters:**
- context (text): The textual representation of the subtree.