Skip to main content

mcp server for polardb postgresql

Project description

PolarDB MySQL MCP Server

Prepare

  1. install uv(if not exist)
    curl -LsSf https://astral.sh/uv/install.sh | sh
  2. 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_WRITE: Enable write operation(default:false)
  • POLARDB_POSTGRESQL_ENABLE_INSER: 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

Cursor

  1. config for mcp.json
{
  "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_INSER": "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

polardb_postgresql_mcp_server-0.8.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polardb_postgresql_mcp_server-0.8.0-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file polardb_postgresql_mcp_server-0.8.0.tar.gz.

File metadata

File hashes

Hashes for polardb_postgresql_mcp_server-0.8.0.tar.gz
Algorithm Hash digest
SHA256 9c2675972033b9983789bb0568ae27f9f9321e65807fc407e227ed8b1b8312c1
MD5 8db46e8efdad102d3badd3c6ca4943e9
BLAKE2b-256 4d2dcbd1322ed8751e57ea24e457f97f5e0dad1c8d00fd88a6f09615112b3071

See more details on using hashes here.

File details

Details for the file polardb_postgresql_mcp_server-0.8.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for polardb_postgresql_mcp_server-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d5e6e0ff2d117d13825b21d03319a136091dc404dc69f0b276a7f4d52cf2c3d1
MD5 39ae1b56b1cba2a07845d5d52b9e5a22
BLAKE2b-256 bf72396801ba20cd41a7f3c5d29627f4d4b9368e68c676973a3dfbeb61a6430c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page