P

PostgreSQL Reference Featured

MCP server · by modelcontextprotocol

Databases npm v0.6.2

Connect the model to a PostgreSQL database with read-only access so it can inspect schemas and run queries safely.

View source ↗ Generate config for multiple servers More servers

Install

registry version 0.6.2

Python (uvx)
uvx postgres-mcp --access-mode=restricted

Setup by client

Pick your client — the config below is generated for this server (local stdio). Copy respects the “Pin version” switch above.

claude_desktop_config.json

{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "<YOUR_DATABASE_URI>"
      }
    }
  }
}

Format verified against the official Claude Desktop docs ↗.

Environment variables

Defined in the server's official registry manifest. Required secrets are shown as <YOUR_…> placeholders in the configs above.

  • DATABASE_URI required secret — Standard PostgreSQL connection string, e.g. postgresql://user:password@localhost:5432/dbname. Keep it in your client config, not on the command line. Get it: Your Postgres deployment (or its provider's connection panel)

Official version check

Reference server ARCHIVED — recommended local option: crystaldba/postgres-mcp

The original @modelcontextprotocol/server-postgres reference server is archived (modelcontextprotocol/servers-archived). The maintained local option recommended by the community is crystaldba/postgres-mcp. This listing previously pointed at a hosted third-party gateway (waystation.ai) — commands below are for the maintained local server, which keeps your database credentials on your own machine.

crystaldba/postgres-mcp ↗ · Archived reference server ↗

What it can do

  • execute_sql
  • list_schemas
  • list_objects
  • analyze_db_health
  • analyze_query_indexes
  • analyze_workload_indexes
  • analyze_query_workload

Common issues

Worried about destructive queries

Run with --access-mode=restricted (the documented default recommendation) to keep the server read-only-ish; unrestricted mode enables writes and DDL. Source: github.com/crystaldba/postgres-mcp ↗

Connection refused / auth failed

Check DATABASE_URI: postgresql://user:password@host:5432/dbname. For hosted databases, allow the client IP or use the provider's proxy connection string. Source: github.com/crystaldba/postgres-mcp ↗

Index-tuning tools report nothing useful

The index analysis tooling benefits from optional Postgres extensions (documented in the README); without them only the basic analyses work. Source: github.com/crystaldba/postgres-mcp ↗

Alternatives

Other community implementations

Independent, non-official implementations of the PostgreSQL MCP server maintained by the community.

Last verified: 2026-10-15 | Sources: crystaldba/postgres-mcp README ↗ · modelcontextprotocol/servers-archived ↗

GitHub

⭐ 3,397 stars · 最近更新于 73 天前 · MIT license

About this server

Postgres MCP Pro does much more than wrap a database connection. Features include: Postgres MCP Pro supports both the Standard Input/Output (stdio) and Server-Sent Events (SSE) transports, for flexibility in different environments. For additional background on why we built Postgres MCP Pro

Summary from the project README — github.com/modelcontextprotocol/servers

Distributed as npm, listed under Databases. Review our MCP security guide before granting access to real data.

Frequently asked questions

What does the PostgreSQL MCP server do?

Postgres MCP Pro does much more than wrap a database connection. Features include: Postgres MCP Pro supports both the Standard Input/Output (stdio) and Server-Sent Events (SSE) transports, for flexibility in different environments. For additional background on why we built Postgres MCP Pro

How do I install PostgreSQL?

Run the install command shown above, then paste the config for your client (Claude Desktop, Claude Code, Cursor, VS Code or Windsurf) into its MCP settings and restart the client.

Is PostgreSQL free to use?

The MCP server itself is free to install. The source is public on https://github.com/modelcontextprotocol/servers. Any third-party service it calls may require its own API key and account.

Which clients support PostgreSQL?

Any MCP-compatible client can use it, including Claude Desktop, Claude Code, Cursor, VS Code, Windsurf and custom agents.

Add this badge

Publish this server? Link back with a badge on your README or site — copy either snippet.

Listed on MCPNav

Markdown

[![Listed on MCPNav](https://mcpnav.net/badge/postgres.svg)](https://mcpnav.net/server/postgres/)

HTML

<a href="https://mcpnav.net/server/postgres/"><img src="https://mcpnav.net/badge/postgres.svg" alt="Listed on MCPNav" height="20"></a>