Add your description here
Project description
PolarDB PostgreSQL MCP Server
Prepare
- install uv(if not exist)
curl -LsSf https://astral.sh/uv/install.sh | sh - The project requires at least Python 3.10, if not available then install Python 3.12
uv python install 3.12
Environment Variables
The following environment variables are required to connect to PolarDB PostgreSQL database,environment Variables can be set in .env file or set in command line
- POLARDB_POSTGRESQL_HOST: Database host address
- POLARDB_POSTGRESQL_PORT: Database port
- POLARDB_POSTGRESQL_USER: Database user
- POLARDB_POSTGRESQL_PASSWORD: Database password
- POLARDB_POSTGRESQL_DBNAME: Database name
- POLARDB_POSTGRESQL_ENABLE_UPDATE: Enable update operation(default:false)
- POLARDB_POSTGRESQL_ENABLE_DELETE: Enable delete operation(default:false)
- POLARDB_POSTGRESQL_ENABLE_INSERT: Enable insert operation(default:false)
- POLARDB_POSTGRESQL_ENABLE_DDL: Enable ddl operation(default:false)
- SSE_BIND_HOST: The host address to bind for SSE mode
- SSE_BIND_PORT: The port to bind for SSE mode
- RUN_MODE: The run mode(sse|stdio),(default:sse)
Build and Run
git clone https://github.com/aliyun/alibabacloud-polardb-mcp-server.git
cd alibabacloud-polardb-mcp-server/polardb-postgresql-mcp-server
uv venv
source .venv/bin/activate
cp .env_example .env #set env file with your database information
uv run server.py
Components
Tools
- execute_sql: execute sql
Resources
- polardb-postgresql://schemas: List all schemas for PolarDB PostgreSQL in the current database
Resource Templates
- polardb-postgresql://{schema}/tables: List all tables for a schema
- polardb-postgresql://{schema}/{table}/field: get the name,type and comment of the field in the table
- polardb-postgresql://{schema}/{table}/data: get data from the table,default limit 50 rows
Usage
Run with source code
{
"mcpServers": {
"polardb-postgresql-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/xxxx/alibabacloud-polardb-mcp-server/polardb-postgresql-mcp-server",
"run",
"server.py"
],
"env": {
"POLARDB_POSTGRESQL_HOST": "127.0.0.1",
"POLARDB_POSTGRESQ_PORT": "15001",
"POLARDB_POSTGRESQ_USER": "xxxx",
"POLARDB_POSTGRESQL_PASSWORD": "xxx",
"POLARDB_POSTGRESQL_DBNAME": "xxx",
"RUN_MODE": "stdio",
"POLARDB_POSTGRESQL_ENABLE_UPDATE": "false",
"POLARDB_POSTGRESQL_ENABLE_UPDATE": "false",
"POLARDB_POSTGRESQL_ENABLE_INSERT": "false",
"POLARDB_POSTGRESQL_ENABLE_DDL": "false"
}
}
}
}
Run with packages from PyPI
{
"mcpServers": {
"polardb-postgresql-mcp-server": {
"command": "uvx",
"args": [
"--from",
"polardb-postgresql-mcp-server",
"run_polardb_postgresql_mcp_server"
],
"env": {
"POLARDB_POSTGRESQL_HOST": "127.0.0.1",
"POLARDB_POSTGRESQL_PORT": "15001",
"POLARDB_POSTGRESQL_USER": "xxxx",
"POLARDB_POSTGRESQL_PASSWORD": "xxx",
"POLARDB_POSTGRESQL_DBNAME": "xxx",
"RUN_MODE": "stdio",
"POLARDB_POSTGRESQL_ENABLE_UPDATE": "false",
"POLARDB_POSTGRESQL_ENABLE_UPDATE": "false",
"POLARDB_POSTGRESQL_ENABLE_INSERT": "false",
"POLARDB_POSTGRESQL_ENABLE_DDL": "false"
}
}
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polardb_postgresql_mcp_server-0.9.0.tar.gz.
File metadata
- Download URL: polardb_postgresql_mcp_server-0.9.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc88a1918b373627d250c51646d7eaec81231b36619d240250ee6117b0eea123
|
|
| MD5 |
c8c2447e31d56c24274e3aa4c96314fc
|
|
| BLAKE2b-256 |
dc14f7f00f664ad8a587d6b11ab72bf05cfcaea706ba9757be172a96ef30c858
|
File details
Details for the file polardb_postgresql_mcp_server-0.9.0-py3-none-any.whl.
File metadata
- Download URL: polardb_postgresql_mcp_server-0.9.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5e3768d7aec8202bd5cbbf97f0ebca4ac4e08453984ff38aa4913f0611a2146
|
|
| MD5 |
2a54c1694e01881cf668306735ab5527
|
|
| BLAKE2b-256 |
c98ff0972ad60a36b22d914273ce694b77ff66cb3eae4a413abec97192c39ea2
|