I open sourced a project I have been building on the side: a Go MCP server that connects Claude Code (or Cursor) directly to a live PostgreSQL database.
Repo: github.com/gupta-akshay/postgres-mcp
The problem it solves
Most "AI plus database" workflows still look like this: copy SQL out of a chat window, paste it into a DB client, run it, copy the output back. It breaks flow, and the assistant never sees your actual schema, so it guesses.
MCP fixes the connection problem. This server is what sits on the other end for Postgres.
What it does
The server exposes nine tools over MCP:
- Schema introspection - real tables, columns, indexes, constraints
-
execute_sql- run queries directly (read only in restricted mode) -
explain_query- EXPLAIN ANALYZE, including against a hypothetical index -
get_top_queries- pull slow queries frompg_stat_statements - Index advisors - recommend indexes using a greedy Database Tuning Advisor built on
hypopg -
analyze_db_health- vacuum, XID wraparound, replication lag, invalid indexes, and more, checked in parallel
That means you can ask "why is this query slow" and the assistant actually runs the EXPLAIN, checks the stats, and can simulate an index before anyone touches the schema.
Why Go
The project is inspired by the Python crystaldba/postgres-mcp. I rebuilt it from scratch in Go so it ships as a single ~15 MB static binary. No Python runtime, no dependency chasing. docker build, point Claude Code at it, done.
Restricted mode wraps every call in a read only transaction, so write protection comes from Postgres itself, not string matching on the query text.
Where to look
The repo has the full setup instructions, the Docker config, and the test suite (unit, integration, and end to end against a real Postgres container with pg_stat_statements and hypopg). CI fails under 95% coverage.
If you spend real time in Claude Code or Cursor and also spend real time worrying about Postgres performance, take a look: github.com/gupta-akshay/postgres-mcp
I wrote up the build in more depth on my blog and on dev.to if you want the architecture and testing details.