- Home
- MCP servers
- AnalyticDB PostgreSQL
AnalyticDB PostgreSQL
- python
11
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"aliyun-alibabacloud-adbpg-mcp-server": {
"command": "uv",
"args": [
"run",
"adbpg-mcp-server",
"--transport",
"stdio"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_DATABASE": "database",
"ADBPG_PASSWORD": "password",
"GRAPHRAG_API_KEY": "graphrag api key",
"LLMEMORY_API_KEY": "llm memory api_key",
"GRAPHRAG_BASE_URL": "graphrag base url",
"LLMEMORY_BASE_URL": "llm memory base_url",
"GRAPHRAG_LLM_MODEL": "graphrag llm model name",
"LLMEMORY_LLM_MODEL": "llm memory model name",
"LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)",
"GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
"LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
"GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
"GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url"
}
}
}
}AnalyticDB PostgreSQL MCP Server provides a focused bridge between AI Agents and AnalyticDB PostgreSQL databases. It enables AI Agents to retrieve database metadata and execute SQL operations through a streamlined MCP interface, simplifying integration and enabling scalable, automated data interactions.
How to use
You will run the MCP server locally and connect your MCP client to it using the stdio transport by default for lightweight integrations. When you need direct API access or debugging, you can switch to the HTTP transport to expose a REST-like interface. The server accepts configuration via environment variables and can execute common SQL operations against AnalyticDB PostgreSQL, such as selecting data, modifying records, and altering schema.
How to install
Prerequisites: you need Python 3.11 or higher and the uv tool for environment and package management.
# Option A: From Source (development)
# 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 B: From PyPI (production/usage)
pip install adbpg-mcp-server
Additional sections
Configuration and runtime notes:
- Environment variables are required to connect to AnalyticDB PostgreSQL and to initialize graph reasoning and memory services. Typical variables include ADBPG_HOST, ADBPG_PORT, ADBPG_USER, ADBPG_PASSWORD, and ADBPG_DATABASE. You also provide keys and endpoints for graph knowledge services and memory modules when you want integrated graph reasoning and long-term memory features.
- The server can operate in two transport modes. The default is stdio, which is suitable for integration with MCP clients. The streamable HTTP mode exposes an HTTP server for REST-like access, testing, or debugging.
- If you start in stdio mode, you typically invoke the runtime command exactly as shown in the usage examples to ensure proper integration with your MCP client setup.
API endpoints and common actions
The MCP server exposes tools to perform common SQL operations against AnalyticDB PostgreSQL and to gather metadata. You can:
- Execute SELECT queries and retrieve results
- Run DML statements (INSERT, UPDATE, DELETE)
- Create, alter, or drop database objects via DDL
- Collect table statistics and obtain query execution plans
- Upload and query knowledge graphs via graphrag endpoints (for enhanced information uses)
- Manage long-term memory for agents with the llm memory endpoints
Available 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
Upload a text file to graphrag to generate a knowledge graph
adbpg_graphrag_query
Query graphrag with specified query string and mode
adbpg_graphrag_upload_decision_tree
Upload a decision tree to graphrag with a root node
adbpg_graphrag_append_decision_tree
Append a subtree to an existing graphrag decision tree at a specified node
adbpg_graphrag_delete_decision_tree
Delete a graphrag sub-decision tree by root node entity
adbpg_llm_memory_add
Add LLM long memory with associated metadata and context
adbpg_llm_memory_get_all
Retrieve all memory records for a user, run, or agent
adbpg_llm_memory_search
Retrieve memories relevant to a query for a user, run, or agent
adbpg_llm_memory_delete_all
Delete all memory records for a user, run, or agent