Skip to main content
Glama
pg-mcp-bridge

pg-mcp-bridge

by Rabin0404

pg-mcp-bridge (MCP server source)

Local stdio MCP bridge for Cursor and Claude Code so you can talk to a remote PostgreSQL database through a PHP/Apache HTTP tunnel.

Cursor / Claude Code  →  pg-mcp-bridge  →  HTTPS  →  PHP tunnel  →  PostgreSQL

PHP tunnel (required on your server)

Upload the PHP files from https://github.com/Rabin0404/pg-mcp-bridge:

  • pg_mcp_tunnel.php

  • config.example.php → copy to config.php and set DB credentials + bearer token

  • .htaccess (optional; blocks web access to config.php)

See that repo’s README for access_mode (readonly | readwrite | full) and curl test steps.

Related MCP server: postgres-mcp

Claude Code setup

Option A — project .mcp.json

Copy examples/claude.mcp.json to your project root as .mcp.json (or merge into an existing one), then set the env values:

{
  "mcpServers": {
    "remote-postgres": {
      "command": "npx",
      "args": ["-y", "pg-mcp-bridge"],
      "env": {
        "PG_MCP_TUNNEL_URL": "https://your-domain.com/pg_mcp_tunnel.php",
        "PG_MCP_TOKEN": "your-bearer-token"
      }
    }
  }
}

Claude Code also supports ${VAR} expansion, for example:

"env": {
  "PG_MCP_TUNNEL_URL": "${PG_MCP_TUNNEL_URL}",
  "PG_MCP_TOKEN": "${PG_MCP_TOKEN}"
}

Option B — CLI

claude mcp add --transport stdio remote-postgres \
  --env PG_MCP_TUNNEL_URL=https://your-domain.com/pg_mcp_tunnel.php \
  --env PG_MCP_TOKEN=your-bearer-token \
  -- npx -y pg-mcp-bridge

Scopes: local (default), project (shared .mcp.json), or user (all projects). See Claude Code MCP docs.

Verify:

claude mcp list
claude mcp get remote-postgres

Cursor setup

Add to Cursor MCP settings (mcp.json):

{
  "mcpServers": {
    "remote-postgres": {
      "command": "npx",
      "args": ["-y", "pg-mcp-bridge"],
      "env": {
        "PG_MCP_TUNNEL_URL": "https://your-domain.com/pg_mcp_tunnel.php",
        "PG_MCP_TOKEN": "your-bearer-token"
      }
    }
  }
}

Develop locally

npm install
npm run build
node dist/index.js

Environment variables

Variable

Required

Description

PG_MCP_TUNNEL_URL

Yes

Full URL to pg_mcp_tunnel.php

PG_MCP_TOKEN

Yes

Same bearer token as in server config.php

MCP tools

  • ping — connectivity + access_mode

  • list_schemas

  • list_tables

  • describe_table

  • query — SQL allowed by server access_mode

License

MIT

Available Tools

5 tools
describe_tableA

Describe columns, types, nullability, defaults, and primary key for a table

Inputs: table (required), schema.

list_schemasA

List non-system PostgreSQL schemas available through the remote tunnel

Inputs: no named parameters.

list_tablesA

List tables and views in a schema

Inputs: schema.

pingA

Check tunnel and PostgreSQL connectivity; returns version, database, user, and access_mode (readonly|readwrite|full)

Inputs: no named parameters.

queryA

Run a single SQL statement. Allowed statements depend on server access_mode: readonly (SELECT/EXPLAIN/SHOW), readwrite (+ INSERT/UPDATE/DELETE), full (+ CREATE/ALTER/DROP and other DDL). Use ping to see the current access_mode. Only one statement per call.

Inputs: sql (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clear, unique purpose: listing schemas, listing tables, describing columns, running SQL queries, and checking connectivity. There is no overlap or ambiguity.

    Naming Consistency5/5

    All tool names use a consistent snake_case verb_noun pattern, such as list_schemas, list_tables, describe_table, query, and ping. The naming is predictable and uniform.

    Tool Count5/5

    With 5 tools, the server covers all essential operations for a PostgreSQL bridge: schema exploration, table metadata, column details, arbitrary SQL execution, and connectivity checks. The count is well-scoped without unnecessary extras.

    Completeness5/5

    The tool surface is complete for its domain, providing full CRUD-like capabilities through the general query tool, plus necessary introspection tools. There are no obvious gaps; it supports both read and write operations as per access mode.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      Enables querying PostgreSQL database metadata including table lists and schema information through the MCP protocol. Supports stdio transport for Cursor/IDE integration as well as HTTP transport with health check endpoints.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for PostgreSQL that enables Cursor and other MCP clients to execute SQL queries, list tables, and explore database schemas via HTTP.
      1,248 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A STDIO bridge for connecting to WordPress sites via the Model Context Protocol (MCP), enabling communication between MCP clients and WordPress installations running the websamurai plugin.
      15 npm
      MIT