skillfed

postgres-mcp

PostgreSQL Tuning and Analysis Tool

postgres-mcp v0.3.0 202.4K downloads/30d#9,648 on PyPI
Permissive license MIT AGING released

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-mcp

uv

uv add postgres-mcp

poetry

poetry add postgres-mcp

Installing 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

postgres mcp serverdatabase tuning ai agentsql explain plan analysisindex optimization toolpostgres health monitoringsafe database access controlai-assisted query optimization
mcp-serverai-agent-integrationdatabase-analysis

More Database packages

Further reading