pg-mcp-bridge
Allows querying and managing a PostgreSQL database through a PHP tunnel, supporting list schemas, tables, describe table, and SQL queries with configurable access modes (readonly, readwrite, full).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pg-mcp-bridge Show me the structure of the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
This repo: Node MCP bridge source → published as npm
pg-mcp-bridgePHP tunnel: download from Rabin0404/pg-mcp-bridge and upload to your PHP host
Cursor / Claude Code → pg-mcp-bridge → HTTPS → PHP tunnel → PostgreSQLPHP tunnel (required on your server)
Upload the PHP files from https://github.com/Rabin0404/pg-mcp-bridge:
pg_mcp_tunnel.phpconfig.example.php→ copy toconfig.phpand set DB credentials + bearer token.htaccess(optional; blocks web access toconfig.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-bridgeScopes: local (default), project (shared .mcp.json), or user (all projects). See Claude Code MCP docs.
Verify:
claude mcp list
claude mcp get remote-postgresCursor 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.jsEnvironment variables
Variable | Required | Description |
| Yes | Full URL to |
| Yes | Same bearer token as in server |
MCP tools
ping— connectivity +access_modelist_schemaslist_tablesdescribe_tablequery— SQL allowed by serveraccess_mode
License
MIT
Available Tools
5 toolsdescribe_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
Scored across 5 tools
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.
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.
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.
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
Related MCP Connectors
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Managed Postgres MCP: projects, SQL, docs search, and storage buckets via OAuth.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables 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.2MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for PostgreSQL that enables Cursor and other MCP clients to execute SQL queries, list tables, and explore database schemas via HTTP.1,248 npmMIT
- AlicenseNot gradedqualityDmaintenanceA 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 npmMIT
- AlicenseNot gradedqualityDmaintenanceProxies STDIO-based MCP clients to streaming HTTP MCP servers, enabling local clients to connect to remote servers.24 npm3MIT