P

Postgres MCP

by YawLabs · io.github.YawLabs/postgres-mcp

Query and manage PostgreSQL databases from Claude Code, Cursor, and any MCP client, with read-only by default and built-in schema introspection, EXPLAIN, and performance diagnostics.

npm Local · stdio GlamaOfficial MCP Registry High confidence

Install

Add to ~/Library/Application Support/Claude/claude_desktop_config.json

Windows / Linux path
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "io-github-yawlabs-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yawlabs/postgres-mcp"
      ],
      "env": {
        "ALLOW_WRITES": "",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MAX_ROWS": "1000",
        "POSTGRES_POOL_MAX": "5",
        "POSTGRES_STATEMENT_TIMEOUT_MS": "30000",
        "POSTGRES_CONNECTION_TIMEOUT_MS": "10000",
        "POSTGRES_SSL_REJECT_UNAUTHORIZED": ""
      }
    }
  }
}

Restart Claude Desktop to activate the new server.

Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)

Windows / Linux path
Windows: .cursor\mcp.json (project) or %USERPROFILE%\.cursor\mcp.json (global)
Linux: .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)
{
  "mcpServers": {
    "io-github-yawlabs-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yawlabs/postgres-mcp"
      ],
      "env": {
        "ALLOW_WRITES": "",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MAX_ROWS": "1000",
        "POSTGRES_POOL_MAX": "5",
        "POSTGRES_STATEMENT_TIMEOUT_MS": "30000",
        "POSTGRES_CONNECTION_TIMEOUT_MS": "10000",
        "POSTGRES_SSL_REJECT_UNAUTHORIZED": ""
      }
    }
  }
}

Cursor usually picks up config changes automatically; if the server does not appear, reload the window.

Add to .mcp.json (project) or ~/.claude.json (global)

Windows / Linux path
Windows: .mcp.json (project) or %USERPROFILE%\.claude.json (global)
Linux: .mcp.json (project) or ~/.claude.json (global)
{
  "mcpServers": {
    "io-github-yawlabs-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yawlabs/postgres-mcp"
      ],
      "env": {
        "ALLOW_WRITES": "",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MAX_ROWS": "1000",
        "POSTGRES_POOL_MAX": "5",
        "POSTGRES_STATEMENT_TIMEOUT_MS": "30000",
        "POSTGRES_CONNECTION_TIMEOUT_MS": "10000",
        "POSTGRES_SSL_REJECT_UNAUTHORIZED": ""
      }
    }
  }
}

The server will be available in the next Claude Code session.

Add to .vscode/mcp.json

Windows / Linux path
Windows: .vscode\mcp.json
Linux: .vscode/mcp.json
{
  "servers": {
    "io-github-yawlabs-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yawlabs/postgres-mcp"
      ],
      "env": {
        "ALLOW_WRITES": "",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MAX_ROWS": "1000",
        "POSTGRES_POOL_MAX": "5",
        "POSTGRES_STATEMENT_TIMEOUT_MS": "30000",
        "POSTGRES_CONNECTION_TIMEOUT_MS": "10000",
        "POSTGRES_SSL_REJECT_UNAUTHORIZED": ""
      }
    }
  }
}

Reload the VS Code window to activate.

Add to ~/.codeium/windsurf/mcp_config.json

Windows / Linux path
Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json
Linux: ~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "io-github-yawlabs-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yawlabs/postgres-mcp"
      ],
      "env": {
        "ALLOW_WRITES": "",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MAX_ROWS": "1000",
        "POSTGRES_POOL_MAX": "5",
        "POSTGRES_STATEMENT_TIMEOUT_MS": "30000",
        "POSTGRES_CONNECTION_TIMEOUT_MS": "10000",
        "POSTGRES_SSL_REJECT_UNAUTHORIZED": ""
      }
    }
  }
}

Restart Windsurf (or refresh its MCP servers panel) to activate the new server.

Windsurf Next uses ~/.codeium/windsurf-next/mcp_config.json. Devin Desktop (the Windsurf rebrand) uses ~/.config/devin/mcp_config.json and imports the Windsurf file.

Add to ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Windows / Linux path
Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
  "mcpServers": {
    "io-github-yawlabs-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yawlabs/postgres-mcp"
      ],
      "env": {
        "ALLOW_WRITES": "",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MAX_ROWS": "1000",
        "POSTGRES_POOL_MAX": "5",
        "POSTGRES_STATEMENT_TIMEOUT_MS": "30000",
        "POSTGRES_CONNECTION_TIMEOUT_MS": "10000",
        "POSTGRES_SSL_REJECT_UNAUTHORIZED": ""
      }
    }
  }
}

Cline reloads cline_mcp_settings.json automatically; if the server does not appear, reload the VS Code window.

Open it from Cline's MCP Servers panel → Configure. Roo Code uses a different file and format.

Configuration

Environment variables this server reads. Secrets stay on your machine.

NameRequiredDescription
ALLOW_WRITES No Set to '1' or 'true' to allow write operations via pg_query and pg_explain ANALYZE-of-writes. Default is unset (read-only).
DATABASE_URL Yes PostgreSQL connection string (required).
POSTGRES_MAX_ROWS No Maximum rows returned by pg_query. Default is 1000. Default: 1000
POSTGRES_POOL_MAX No Maximum pool connections. Default is 5. Default: 5
POSTGRES_STATEMENT_TIMEOUT_MS No Per-statement timeout in milliseconds. Default is 30000. Default: 30000
POSTGRES_CONNECTION_TIMEOUT_MS No TCP connect timeout in milliseconds. Default is 10000. Default: 10000
POSTGRES_SSL_REJECT_UNAUTHORIZED No Set to 'false' to skip TLS cert verification (connection remains encrypted). Default is unset.

Similar servers