postgres-mcp
PostgreSQL Tuning and Analysis Tool
What it is and what it does
Postgres MCP is a Model Context Protocol server that exposes PostgreSQL database operations to AI agents and assistants. It acts as a bridge between AI tools (like Claude, Cursor, or Windsurf) and your database, enabling agents to analyze schemas, review query performance, explore index tuning opportunities, and execute SQL safely. The package wraps psycopg and pglast to provide schema-aware SQL generation, EXPLAIN plan analysis, and database health diagnostics including index health, connection utilization, buffer cache, and replication lag.
It runs as a standalone server via Docker or Python (3.12+) and supports both stdio and SSE transports for flexible deployment. Access control is configurable: unrestricted mode for development allows full read/write access, while restricted mode limits operations to read-only transactions and resource constraints suitable for production. The package depends on attrs, humanize, instructor, mcp, pglast, psycopg-pool, and psycopg.
Use it for:
- Debugging slow ORM queries by asking an AI agent to review EXPLAIN plans and suggest indexes without manual analysis.
- Exploring hypothetical index scenarios to find the best solution for a workload before committing schema changes.
- Running health checks on production databases (in restricted mode) to identify connection leaks, vacuum issues, or replication lag.
- Generating context-aware SQL from natural language prompts based on detailed schema understanding.
- Automating routine database maintenance tasks through AI agents while enforcing read-only constraints in production.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Model Context Protocol server that connects AI agents to PostgreSQL databases for analysis, tuning, and safe query execution with health checks and index optimization.
Yes, if you are actively using an MCP-compatible AI assistant (Claude, Cursor, Windsurf) and want to give it safe, structured access to PostgreSQL for tuning and analysis. The low install friction and permissive license are favorable. However, verify current maintenance status before relying on it in production—the package is aging with no recent commit history visible, and support clarity is needed.
Install
postgres-mcp on PyPI
pip
pip install postgres-mcpuv
uv add postgres-mcppoetry
poetry add postgres-mcpInstalling postgres-mcp
Before you install
Low friction installation via pipx or uv; package is aging (455 days since release) with no recent commits tracked, so maintenance status is unclear—verify active support before production use.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, suitable for both development and commercial projects.
Quickstart
# Install via pipx
pipx install postgres-mcp
# Or via uv
uv pip install postgres-mcp
# Configure in Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
# {
# "mcpServers": {
# "postgres": {
# "command": "postgres-mcp",
# "args": ["--access-mode=unrestricted"],
# "env": {"DATABASE_URI": "postgresql://user:pass@localhost:5432/dbname"}
# }
# }
# }
# Then use in Claude or other MCP client to query and analyze your database.
Requires Python 3.12 or higher; requires a running PostgreSQL database with valid connection credentials; requires an MCP-compatible AI assistant (Claude, Cursor, Windsurf, etc.) to interact with the server.
Verify before relying
- Whether the package is actively maintained—repo commit history and current maintainer status are not available in the fact sheet.
- Performance characteristics when analyzing large databases or thousands of possible indexes.
- Specific constraints or limitations of restricted mode for production environments.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — attrs, humanize, instructor, mcp, pglast, psycopg-pool, psycopg |
| Maintenance | aging — 455 days since the last release |
| First released | |
| Downloads | 202,443/month — #9,648 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: postgres_mcp-0.3.0-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
arcade-mcp-serverArcade MCP Server provides a FastAPI-like…
permissive · top 15,000 on PyPI
debsecan-mcpAn MCP server that scans Debian systems for…
unclear · top 15,000 on PyPI
excel-mcp-serverProvides a Model Context Protocol server that…
unclear · top 15,000 on PyPI
mcp-clickhouseAn MCP server that exposes ClickHouse database…
permissive · top 15,000 on PyPI
mcp-server-odooAn MCP server that bridges AI assistants like…
copyleft · top 5,000 on PyPI
snowflake-labs-mcpA deprecated MCP server that previously…
unclear · top 15,000 on PyPI
pagerduty-mcpAn MCP (Model Context Protocol) server that…
unclear · top 15,000 on PyPI
microsoft-fabric-rti-mcpAn MCP server that bridges AI agents to…
permissive · top 15,000 on PyPI
pgclipgcli is a command-line interface for…
permissive · top 15,000 on PyPI
blender-mcpBlenderMCP is a Model Context Protocol server…
permissive · top 15,000 on PyPI