Skip to main content
Glama
Rabin0404

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: PostgreSQL SSH MCP Server

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

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Rabin0404/pg-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server