← all repositories
subnetmarco/pgmcp

Put an AI translator between chatbots and your Postgres

It exposes any PostgreSQL database to AI assistants through natural language while keeping the interaction strictly read-only.

pgmcp
Not currently ranked — collecting fresh signals.
star history

What it does

PGMCP is a Model Context Protocol server that bridges MCP-compatible clients—Cursor, Claude Desktop, VS Code—and any existing PostgreSQL database. You ask questions in plain English; it translates them into SQL, streams back results, and enforces read-only access at the transaction level. It ships as both a server binary and a standalone CLI client, with container manifests included.

The interesting bit

The server caches your database schema to help the LLM—defaulting to gpt-4o-mini through OpenAI, though the architecture diagram also nods toward local Ollama instances—generate context-aware queries. When the AI inevitably hallucinates a column name or stumbles over PostgreSQL case-sensitivity rules, the system catches the bad SQL and returns a helpful error rather than crashing. A dedicated search tool will trawl every text column in every table, which feels like a blunt instrument but is kept in check by query timeouts and read-only enforcement.

Key highlights

  • Read-only by design: blocks INSERT, UPDATE, DELETE, and other write operations at the SQL level.
  • Zero schema changes required: works with mixed-case table names, composite keys, and any existing Postgres layout.
  • Multiple output formats: chatbots use the MCP HTTP endpoint; humans can use the CLI for table, JSON, or CSV output.
  • Graceful AI failure recovery: invalid generated SQL is intercepted and surfaced with suggestions instead of raw stack traces.
  • Optional bearer-token authentication and automatic pagination for large result sets.

Caveats

  • The README hints at local LLM support via Ollama in a diagram, but every documented configuration path and error-handling mechanism centers on the OpenAI API, so the local route remains vague.
  • It is strictly read-only, so any workflow requiring an AI agent to update or insert records is explicitly out of scope.

Verdict

A solid fit if you want AI assistants or non-technical users to explore PostgreSQL data without writing SQL or risking accidental mutations. Look elsewhere if you need the agent to write data back.

Frequently asked

What is subnetmarco/pgmcp?
It exposes any PostgreSQL database to AI assistants through natural language while keeping the interaction strictly read-only.
Is pgmcp open source?
Yes — subnetmarco/pgmcp is an open-source project tracked on heatdrop.
What language is pgmcp written in?
subnetmarco/pgmcp is primarily written in Go.
How popular is pgmcp?
subnetmarco/pgmcp has 540 stars on GitHub.
Where can I find pgmcp?
subnetmarco/pgmcp is on GitHub at https://github.com/subnetmarco/pgmcp.

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