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.
Download from Github
git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
Add the following configuration to the MCP client configuration file:
"mcpServers": {
"adbpg-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/adbpg-mcp-server",
"run",
"adbpg-mcp-server"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_PASSWORD": "password",
"ADBPG_DATABASE": "database"
}
}
}
pip install adbpg_mcp_server
"mcpServers": {
"adbpg-mcp-server": {
"command": "uvx",
"args": [
"adbpg_mcp_server"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_PASSWORD": "password",
"ADBPG_DATABASE": "database"
}
}
}
execute_select_sql
: Execute SELECT SQL queries on the AnalyticDB PostgreSQL serverexecute_dml_sql
: Execute DML (INSERT, UPDATE, DELETE) SQL queries on the AnalyticDB PostgreSQL serverexecute_ddl_sql
: Execute DDL (CREATE, ALTER, DROP) SQL queries on the AnalyticDB PostgreSQL serveranalyze_table
: Collect table statisticsexplain_query
: Get query execution plan
adbpg:///schemas
: Get all schemas in the database
adbpg:///{schema}/tables
: List all tables in a specific schemaadbpg:///{schema}/{table}/ddl
: Get table DDLadbpg:///{schema}/{table}/statistics
: Show table statistics
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
- Python 3.10 or higher
- Required packages:
- mcp >= 1.4.0
- psycopg >= 3.1.0
- python-dotenv >= 1.0.0
- pydantic >= 2.0.0
# Create and activate virtual environment
uv venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
# Install dependencies
uv pip install -e .
# Run server
uv run adbpg-mcp-server