Postgres MCP Server

Query any Postgres database using natural language.

Local serverstdioGo

What is the Postgres MCP Server?

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

Configuration and credentials

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

More MCP options

Compare MCP servers by category, or browse hosted MCP servers if you prefer an endpoint over a local process.

Maintainer setup documentation.

How to install the Postgres 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

Query any Postgres database using natural language. Confirm the tools offered by your installed version in the connected client. Tool availability and permissions depend on the server and account configuration.