← all repositories
crystaldba/postgres-mcp

An MCP Server That Turns AI Assistants Into Postgres DBAs

It wires Postgres health checks, index tuning, and safe SQL execution into the Model Context Protocol so AI agents can stop guessing.

3.3k stars Python Coding AssistantsLLMOps · Eval
postgres-mcp
Velocity · 7d
+3.9
★ / day
Trend
steady
star history

What it does

Postgres MCP Pro is a Model Context Protocol server that hands your AI agent a curated Postgres toolkit. It can diagnose database health, simulate index changes, review EXPLAIN plans, and execute SQL through configurable read-only or unrestricted access modes. The server speaks both stdio and SSE, fitting into local agent loops or shared remote setups.

The interesting bit

Rather than dumping a raw connection into the context window, it packages operations as discrete MCP tools—an intentional bet that tool support is the only truly portable surface across clients like Claude, Cursor, and Windsurf. The index tuner is the standout feature, exploring thousands of hypothetical indexes via hypopg to find workload-specific optimizations.

Key highlights

  • Safe SQL execution with restricted (read-only, time-limited) and unrestricted modes for prod and dev.
  • Index tuning that explores thousands of candidate indexes using workload analysis; requires optional pg_stat_statements and hypopg extensions.
  • Database health checks covering vacuum status, buffer cache, connection saturation, replication lag, and sequence limits.
  • Schema intelligence for context-aware SQL generation based on actual table structures.
  • SSE transport support allows multiple MCP clients to share one server instance.

Caveats

  • Full index tuning and performance analysis depend on installing pg_stat_statements and hypopg; self-managed Postgres may need manual configuration changes and system packages.
  • Restricted mode currently limits only execution time, leaving other resource guardrails unspecified.
  • The maintainers recommend Docker over native Python to avoid “environment-specific issues.”

Verdict

Handy if you want an AI assistant to debug ORM sludge or recommend indexes without granting it full production access. Less compelling if you already have a mature observability stack and prefer to read your own EXPLAIN output.

Frequently asked

What is crystaldba/postgres-mcp?
It wires Postgres health checks, index tuning, and safe SQL execution into the Model Context Protocol so AI agents can stop guessing.
Is postgres-mcp open source?
Yes — crystaldba/postgres-mcp is open source, released under the MIT license.
What language is postgres-mcp written in?
crystaldba/postgres-mcp is primarily written in Python.
How popular is postgres-mcp?
crystaldba/postgres-mcp has 3.3k stars on GitHub and is currently holding steady.
Where can I find postgres-mcp?
crystaldba/postgres-mcp is on GitHub at https://github.com/crystaldba/postgres-mcp.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.