P

Postgres MCP

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

Native MCP server for PostgreSQL that reads credentials from .env at runtime with flexible key mapping, configurable tool selection, and read-only mode by default, providing a structured, safe interface for LLMs to interact with databases.

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-edelciomolina-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@edelciomolina/postgres-mcp"
      ],
      "env": {
        "MCP_KEY_HOST": "<VALUE>",
        "MCP_KEY_PORT": "<VALUE>",
        "MCP_KEY_NAME": "<VALUE>",
        "MCP_KEY_USER": "<VALUE>",
        "MCP_KEY_PASS": "<VALUE>",
        "MCP_KEY_SSLMODE": "<VALUE>",
        "DB_HOST": "<VALUE>",
        "DB_NAME": "<VALUE>",
        "DB_PASS": "<VALUE>",
        "DB_PORT": "<VALUE>",
        "DB_USER": "<VALUE>",
        "DB_SSLMODE": "<VALUE>",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MCP_ALLOW_WRITE": "false"
      }
    }
  }
}

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-edelciomolina-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@edelciomolina/postgres-mcp"
      ],
      "env": {
        "MCP_KEY_HOST": "<VALUE>",
        "MCP_KEY_PORT": "<VALUE>",
        "MCP_KEY_NAME": "<VALUE>",
        "MCP_KEY_USER": "<VALUE>",
        "MCP_KEY_PASS": "<VALUE>",
        "MCP_KEY_SSLMODE": "<VALUE>",
        "DB_HOST": "<VALUE>",
        "DB_NAME": "<VALUE>",
        "DB_PASS": "<VALUE>",
        "DB_PORT": "<VALUE>",
        "DB_USER": "<VALUE>",
        "DB_SSLMODE": "<VALUE>",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MCP_ALLOW_WRITE": "false"
      }
    }
  }
}

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-edelciomolina-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@edelciomolina/postgres-mcp"
      ],
      "env": {
        "MCP_KEY_HOST": "<VALUE>",
        "MCP_KEY_PORT": "<VALUE>",
        "MCP_KEY_NAME": "<VALUE>",
        "MCP_KEY_USER": "<VALUE>",
        "MCP_KEY_PASS": "<VALUE>",
        "MCP_KEY_SSLMODE": "<VALUE>",
        "DB_HOST": "<VALUE>",
        "DB_NAME": "<VALUE>",
        "DB_PASS": "<VALUE>",
        "DB_PORT": "<VALUE>",
        "DB_USER": "<VALUE>",
        "DB_SSLMODE": "<VALUE>",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MCP_ALLOW_WRITE": "false"
      }
    }
  }
}

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-edelciomolina-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@edelciomolina/postgres-mcp"
      ],
      "env": {
        "MCP_KEY_HOST": "<VALUE>",
        "MCP_KEY_PORT": "<VALUE>",
        "MCP_KEY_NAME": "<VALUE>",
        "MCP_KEY_USER": "<VALUE>",
        "MCP_KEY_PASS": "<VALUE>",
        "MCP_KEY_SSLMODE": "<VALUE>",
        "DB_HOST": "<VALUE>",
        "DB_NAME": "<VALUE>",
        "DB_PASS": "<VALUE>",
        "DB_PORT": "<VALUE>",
        "DB_USER": "<VALUE>",
        "DB_SSLMODE": "<VALUE>",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MCP_ALLOW_WRITE": "false"
      }
    }
  }
}

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-edelciomolina-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@edelciomolina/postgres-mcp"
      ],
      "env": {
        "MCP_KEY_HOST": "<VALUE>",
        "MCP_KEY_PORT": "<VALUE>",
        "MCP_KEY_NAME": "<VALUE>",
        "MCP_KEY_USER": "<VALUE>",
        "MCP_KEY_PASS": "<VALUE>",
        "MCP_KEY_SSLMODE": "<VALUE>",
        "DB_HOST": "<VALUE>",
        "DB_NAME": "<VALUE>",
        "DB_PASS": "<VALUE>",
        "DB_PORT": "<VALUE>",
        "DB_USER": "<VALUE>",
        "DB_SSLMODE": "<VALUE>",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MCP_ALLOW_WRITE": "false"
      }
    }
  }
}

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-edelciomolina-postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@edelciomolina/postgres-mcp"
      ],
      "env": {
        "MCP_KEY_HOST": "<VALUE>",
        "MCP_KEY_PORT": "<VALUE>",
        "MCP_KEY_NAME": "<VALUE>",
        "MCP_KEY_USER": "<VALUE>",
        "MCP_KEY_PASS": "<VALUE>",
        "MCP_KEY_SSLMODE": "<VALUE>",
        "DB_HOST": "<VALUE>",
        "DB_NAME": "<VALUE>",
        "DB_PASS": "<VALUE>",
        "DB_PORT": "<VALUE>",
        "DB_USER": "<VALUE>",
        "DB_SSLMODE": "<VALUE>",
        "DATABASE_URL": "<VALUE>",
        "POSTGRES_MCP_ALLOW_WRITE": "false"
      }
    }
  }
}

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
MCP_KEY_HOST No Name of the .env variable that holds the database host
MCP_KEY_PORT No Name of the .env variable that holds the database port
MCP_KEY_NAME No Name of the .env variable that holds the database name
MCP_KEY_USER No Name of the .env variable that holds the database user
MCP_KEY_PASS No Name of the .env variable that holds the database password
MCP_KEY_SSLMODE No Name of the .env variable that holds the SSL mode (e.g. require)
DB_HOST No PostgreSQL host.
DB_NAME No PostgreSQL database name.
DB_PASS No PostgreSQL password.
DB_PORT No PostgreSQL port (default: 5432).
DB_USER No PostgreSQL user.
DB_SSLMODE No SSL mode (e.g., require, disable).
DATABASE_URL No Full PostgreSQL connection string. If provided, individual credential variables are ignored.
POSTGRES_MCP_ALLOW_WRITE No Set to 'true' to enable write-capable tools. Defaults to 'false'. Default: false

Similar servers