# I just published Postgres MCP Server in Go!

> Source: <https://dev.to/akshay_gupta/i-just-published-postgres-mcp-server-in-go-10ab>
> Published: 2026-07-04 06:22:20+00:00

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](https://github.com/gupta-akshay/postgres-mcp)

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.

The server exposes nine tools over MCP:

`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 from `pg_stat_statements`

`hypopg`

`analyze_db_health`

- vacuum, XID wraparound, replication lag, invalid indexes, and more, checked in parallelThat 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.

The project is inspired by the Python [crystaldba/postgres-mcp](https://github.com/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.

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](https://github.com/gupta-akshay/postgres-mcp)

I wrote up the build in more depth on my [blog](https://www.akshaygupta.live/blog/postgres-mcp-server) and on [dev.to](https://dev.to/akshay_gupta/postgres-mcp-in-go-giving-claude-code-a-live-line-to-your-database-1m7m) if you want the architecture and testing details.
