Postgres MCP MCP Server

Query any Postgres database using natural language.

Local serverstdioGo

What is the Postgres MCP MCP server?

Postgres MCP MCP server is a locally run integration for AI assistants that speak the Model Context Protocol. Query any Postgres database using natural language.

What you get

PGMCP connects AI assistants to any PostgreSQL database through natural language queries. Ask questions in plain English and get structured SQL results with automatic streaming and robust error handling.

  • Natural Language to SQL — Ask questions in plain English
  • Automatic Streaming — Handles large result sets automatically
  • Safe Read-Only Access — Prevents any write operations
  • Text Search — Search across all text columns
  • Multiple Output Formats — Table, JSON, and CSV
  • PostgreSQL Case Sensitivity — Handles mixed-case table names correctly

Setting it up

Setup follows the usual MCP pattern — install or clone the server, register it in your client's configuration file, restart the client. The configuration blocks on this page cover the common clients.

What the assistant can call

Once Postgres MCP is connected, these are the calls the assistant has available:

  • Prerequisites — The Prerequisites tool exposed by this server

Configuration and credentials

You will need 3 environment variables: DATABASE_URL, OPENAI_API_KEY, HTTP_PATH. The server will not start without them, which is usually why the tools fail to appear on a first run. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

  • PostgreSQL database (existing database with your schema) - OpenAI API key (optional, for AI-powered SQL generation)

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • Missing credentials fail quietly in some clients — if no tools show up, check the environment block first.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the postgres mcp mcp server does with a few real requests.

Choosing this one

This sits in the database access group, where several servers overlap in what they claim to do but differ sharply once you actually set them up. Postgres MCP's toolset — Prerequisites — is a fair guide to whether it matches your workflow.

This entry was verified against Postgres MCP's own documentation before publication; SyncDev keeps the directory reviewed rather than auto-generated.

Available tools

ToolWhat it does
PrerequisitesThe Prerequisites tool exposed by this server.

How to install the Postgres MCP MCP server

{
  "mcpServers": {
    "pgmcp": {
      "transport": {
        "type": "http",
        "url": "http://localhost:8080/mcp"
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

  • PostgreSQL database (existing database with your schema) - OpenAI API key (optional, for AI-powered SQL generation)
VariableDescriptionRequired
DATABASE_URLEndpoint or connection string the server talks to.Yes
OPENAI_API_KEYCredential the server authenticates with.Yes
HTTP_PATHFilesystem location the server is allowed to use.Optional

Example prompts to try

  • Use Postgres MCP to Prerequisites.

Frequently asked questions

It connects Postgres MCP to MCP-compatible AI assistants such as Claude and Cursor, exposing 1 tool (Prerequisites) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Postgres MCP directly.