PostgreSQL MCP Server

Official

Query your PostgreSQL database with natural language

GitHub8.2k
postgresqlsqldatabaseofficialread-onlylocal

The official PostgreSQL MCP server from Anthropic lets your AI assistant read and query any PostgreSQL database. Ask questions in plain English — the AI translates them into SQL and returns results instantly. The server runs locally, so your data and connection credentials never leave your machine. Supports schema inspection, table listing, and arbitrary read queries. Write queries are not supported by default, keeping your data safe.

Install Config

Config file: ~/Library/Application Support/Claude/claude_desktop_config.json· Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres"
      ],
      "env": {
        "POSTGRES_URL": "postgresql://user:password@localhost:5432/mydb"
      }
    }
  }
}

Required environment variables:

  • POSTGRES_URLPostgreSQL connection string(e.g. postgresql://user:password@localhost:5432/mydb)

Available Tools (3)

Tool nameDescription
queryExecute a read-only SQL query against the database
list_tablesList all tables in the connected database
describe_tableGet the full schema for a specific table

Example Prompts

  • What tables are in my database?
  • Show me the 10 most recent orders
  • How many users signed up this week?
  • What is the schema for the products table?
  • Find all orders over $500 placed in the last 30 days

Pros & Cons

Pros

  • Official Anthropic-maintained server
  • Read-only by default — safe for production
  • All data stays on your machine
  • Works with all major MCP clients

Cons

  • PostgreSQL only — not MySQL or MongoDB
  • No write support by default
  • Requires a running PostgreSQL instance

Who Is This For?

  • ·Developers who want conversational access to their app database
  • ·Data analysts wanting AI-assisted SQL generation
  • ·Teams demoing data capabilities without writing queries

When to use: Use this server when you have a PostgreSQL database and want to explore your data, generate reports, or answer questions without writing SQL yourself.

Supported Clients

Related Use Cases