AnalyticDB PostgreSQL MCP Server
Serves as a universal interface between AI Agents and AnalyticDB PostgreSQL databases, enabling metadata retrieval and SQL execution, with additional capabilities for knowledge graph and LLM memory management.
README
AnalyticDB PostgreSQL MCP Server
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.
# 1. Clone the repository
git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
cd alibabacloud-adbpg-mcp-server
# 2. Create and activate a virtual environment using uv
uv venv .venv
source .venv/bin/activate # On Linux/macOS
# .\.venv\Scripts\activate # On Windows
# 3. Install the project in editable mode
uv pip install -e .
Option 2: From PyPI (for Production/Usage)
This is the simplest way to install the server for direct use within your projects.
pip install adbpg-mcp-server
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.
# Run using the default transport (stdio)
uv run adbpg-mcp-server
# Or explicitly specify the transport
uv run adbpg-mcp-server --transport stdio
Streamable-HTTP Mode
This mode exposes an HTTP server, which is useful for testing, debugging, or direct integration via REST APIs.
# Run the server in HTTP mode on the default host and port (127.0.0.1:3000)
uv run adbpg-mcp-server --transport http
# Specify a custom host and port
uv run adbpg-mcp-server --transport http --host 0.0.0.0 --port 3000
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
"mcpServers": {
"adbpg-mcp-server": {
"command": "uv",
"args": [
"run",
"adbpg-mcp-server",
"--transport",
"stdio"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_PASSWORD": "password",
"ADBPG_DATABASE": "database",
"GRAPHRAG_API_KEY": "graphrag llm api key",
"GRAPHRAG_BASE_URL": "graphrag llm base url",
"GRAPHRAG_LLM_MODEL": "graphrag llm model name",
"GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
"GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
"GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
"LLMEMORY_API_KEY": "llm memory api_key",
"LLMEMORY_BASE_URL": "llm memory base_url",
"LLMEMORY_LLM_MODEL": "llm memory model name",
"LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
"LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
}
}
}
Note: Since
stdiois the default, you can optionally omit"--transport", "stdio"from theargsarray.
Example for Streamable-HTTP Transport
"mcpServers": {
"adbpg-mcp-server": {
"command": "uv",
"args": [
"run",
"adbpg-mcp-server",
"--transport",
"http",
"--port",
"3000"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_PASSWORD": "password",
"ADBPG_DATABASE": "database",
"GRAPHRAG_API_KEY": "graphrag llm api key",
"GRAPHRAG_BASE_URL": "graphrag llm base url",
"GRAPHRAG_LLM_MODEL": "graphrag llm model name",
"GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
"GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
"GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
"LLMEMORY_API_KEY": "llm memory api_key",
"LLMEMORY_BASE_URL": "llm memory base_url",
"LLMEMORY_LLM_MODEL": "llm memory model name",
"LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
"LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
}
}
}
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 tomix.
-
adbpg_graphrag.upload_decision_tree(context text, root_node text)- Description: Upload a decision tree with the specified
root_node. If theroot_nodedoes 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.
- Description: Upload a decision tree with the specified
-
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.root_node_id(text): The ID of the node to which the subtree will be appended.
- Description: Append a subtree to an existing decision tree at the node specified by
-
adbpg_graphrag.delete_decision_tree(root_node_entity text)- Description: Delete a sub-decision tree under the node specified by
root_node_entity. - Parameters:
root_node_entity(text): The ID of the root node of the sub-decision tree to be deleted.
- Description: Delete a sub-decision tree under the node specified by
-
adbpg_llm_memory_add- Description: Add LLM long memory.
- Parameters:
messages(json): The name of the file to be uploaded.user_id(text): The user id.run_id(text): The run id.agent_id(text): The agent id.metadata(json): The metadata json(optional).memory_type(text): The memory type(optional).prompt(text): The prompt(optional). Note:
At least one ofuser_id,run_id, oragent_idshould be provided.
-
adbpg_llm_memory_get_all- Description: Retrieves all memory records associated with a specific user, run or agent.
- Parameters:
user_id(text): User ID (optional). If provided, fetch all memories for this user.run_id(text): Run ID (optional).agent_id(text): Agent ID (optional). If provided, fetch all memories for this agent. Note:
At least one ofuser_id,run_id, oragent_idshould be provided.
-
adbpg_llm_memory_search- Description: Retrieves memories relevant to the given query for a specific user, run, or agent.
- Parameters:
query(text): The search query string.user_id(text): User ID (optional). If provided, fetch all memories for this user.run_id(text): Run ID (optional).agent_id(text): Agent ID (optional). If provided, fetch all memories for this agent.filter(json): Additional filter conditions in JSON format (optional). Note:
At least one ofuser_id,run_id, oragent_idshould be provided.
-
adbpg_llm_memory_delete_all:- Description: Delete all memory records associated with a specific user, run or agent.
- Parameters:
user_id(text): User ID (optional). If provided, fetch all memories for this user.run_id(text): Run ID (optional).agent_id(text): Agent ID (optional). If provided, fetch all memories for this agent. Note:
At least one ofuser_id,run_id, oragent_idshould be provided.
Resources
Built-in Resources
adbpg:///schemas: Get all schemas in the database
Resource Templates
adbpg:///{schema}/tables: List all tables in a specific schemaadbpg:///{schema}/{table}/ddl: Get table DDLadbpg:///{schema}/{table}/statistics: Show table statistics
Environment Variables
MCP Server requires the following environment variables to connect to AnalyticDB PostgreSQL instance:
ADBPG_HOST: Database host addressADBPG_PORT: Database portADBPG_USER: Database usernameADBPG_PASSWORD: Database passwordADBPG_DATABASE: Database name
MCP Server requires the following environment variables to initialize graphRAG and llm memory server:
API_KEY: API key for LLM provider or embedding APIBASE_URL: Base URL for LLM or embedding service endpointLLM_MODEL: LLM model name or identifierEMBEDDING_MODEL: Embedding model name or identifier
Dependencies
- Python 3.11 or higher
uv(for environment and package management)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。