by aliyun
Provides a universal interface for AI agents to access AnalyticDB PostgreSQL, enabling metadata retrieval, SQL execution, graphRAG operations, and LLM memory management.
The server acts as a bridge between AI agents and AnalyticDB PostgreSQL databases, allowing agents to fetch schema information, run SELECT/DML/DDL statements, obtain execution plans, and interact with integrated GraphRAG and LLM memory services.
uv, or install the PyPI package adbpg_mcp_server via pip install adbpg_mcp_server.mcpServers with the appropriate command, arguments, and required environment variables (database connection details, GraphRAG keys, LLM‑memory keys).uv run adbpg-mcp-server or uvx adbpg_mcp_server).uv) and pip‑installed package (uvx).mcp>=1.4.0, psycopg>=3.1.0, python-dotenv>=1.0.0, pydantic>=2.0.0.uv (or uvx for the pip package). Adjust the command and args accordingly.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.
You can set up the server either from the source code for development or by installing it from PyPI for direct use.
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 .
This is the simplest way to install the server for direct use within your projects.
pip install adbpg-mcp-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.
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
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
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.
"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.
"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)"
}
}
}
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
filename (text): The name of the file to be uploaded.context (text): The textual content of the file.adbpg_graphrag_query
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)
root_node. If the root_node does not exist, a new decision tree will be created.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)
root_node_id.context (text): The textual representation of the subtree.root_node_id (text): The ID of the node to which the subtree will be appended.adbpg_graphrag.delete_decision_tree(root_node_entity text)
root_node_entity.root_node_entity (text): The ID of the root node of the sub-decision tree to be deleted.adbpg_llm_memory_add
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:user_id, run_id, or agent_id should be provided.adbpg_llm_memory_get_all
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:user_id, run_id, or agent_id should be provided.adbpg_llm_memory_search
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:user_id, run_id, or agent_id should be provided.adbpg_llm_memory_delete_all:
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:user_id, run_id, or agent_id should be provided.adbpg:///schemas: Get all schemas in the databaseadbpg:///{schema}/tables: List all tables in a specific schemaadbpg:///{schema}/{table}/ddl: Get table DDLadbpg:///{schema}/{table}/statistics: Show table statisticsMCP 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 nameMCP 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 identifieruv (for environment and package management)Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by googleapis
An MCP server that streamlines database tool development by handling connection pooling, authentication, observability, and secure access, allowing agents to interact with databases via natural language.
by bytebase
Provides a universal gateway that lets MCP‑compatible clients explore and query MySQL, PostgreSQL, SQL Server, MariaDB, and SQLite databases through a single standardized interface.
by designcomputer
Enables secure interaction with MySQL databases via the Model Context Protocol, allowing AI applications to list tables, read contents, and execute queries safely.
by benborla
Provides read‑only access to MySQL databases for large language models, allowing schema inspection and safe execution of SQL queries.
by neo4j-contrib
Enables natural‑language interaction with Neo4j databases, allowing large language models to query, modify, and manage graph data through multiple transport modes.
by mongodb-js
Provides a Model Context Protocol server that enables interaction with MongoDB databases and MongoDB Atlas clusters through a unified API.
by ClickHouse
Enables AI assistants to run read‑only ClickHouse queries, list databases and tables, and execute embedded chDB queries through an MCP interface.
by neondatabase
Interact with Neon Postgres databases using natural language commands through the Model Context Protocol, enabling conversational database creation, migration, and query execution.
by domdomegg
Provides read and write access to Airtable bases for AI systems, enabling inspection of schemas and manipulation of records.
{
"mcpServers": {
"adbpg-mcp-server": {
"command": "uv",
"args": [
"run",
"adbpg-mcp-server"
],
"env": {
"ADBPG_HOST": "<YOUR_HOST>",
"ADBPG_PORT": "<YOUR_PORT>",
"ADBPG_USER": "<YOUR_USERNAME>",
"ADBPG_PASSWORD": "<YOUR_PASSWORD>",
"ADBPG_DATABASE": "<YOUR_DATABASE>",
"GRAPHRAG_API_KEY": "<YOUR_GRAPHRAG_API_KEY>",
"GRAPHRAG_BASE_URL": "<YOUR_GRAPHRAG_BASE_URL>",
"GRAPHRAG_LLM_MODEL": "<YOUR_GRAPHRAG_LLM_MODEL>",
"GRAPHRAG_EMBEDDING_MODEL": "<YOUR_GRAPHRAG_EMBEDDING_MODEL>",
"GRAPHRAG_EMBEDDING_API_KEY": "<YOUR_GRAPHRAG_EMBEDDING_API_KEY>",
"GRAPHRAG_EMBEDDING_BASE_URL": "<YOUR_GRAPHRAG_EMBEDDING_BASE_URL>",
"LLMEMORY_API_KEY": "<YOUR_LLMEMORY_API_KEY>",
"LLMEMORY_BASE_URL": "<YOUR_LLMEMORY_BASE_URL>",
"LLMEMORY_LLM_MODEL": "<YOUR_LLMEMORY_LLM_MODEL>",
"LLMEMORY_EMBEDDING_MODEL": "<YOUR_LLMEMORY_EMBEDDING_MODEL>"
}
}
}
}claude mcp add adbpg-mcp-server uv run adbpg-mcp-server