← Back to directory
P

PostgreSQL MCP Server

Official
Read-only DB access for safe analysis
GitHub source repository ↗
★ 5.4k Stars Category · Database Popular
This server connects to PostgreSQL in read-only mode and exposes schema information alongside query access. It helps models write and explain SQL without modifying production data, making it useful for analysis and troubleshooting.

Tools

query
Run a read-only SQL query
list_schemas
List all schemas in the database
list_tables
List tables in a selected schema
describe_table
Inspect a table's columns and data types

Setup

Pass a PostgreSQL connection string as a startup argument. Use a dedicated read-only database account.
claude_desktop_config.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly:pwd@localhost/db"
      ]
    }
  }
}

Use cases

Generate reporting queries from natural-language requests
Investigate slow queries and missing indexes
Help new team members understand the database schema

Supported clients

Claude DesktopFull support
CursorFull support
ClinePartial support