db-bridge
This server is a local-first PostgreSQL MCP bridge that lets MCP clients query, inspect, and manage a PostgreSQL database over stdio, without sending data to a cloud service.
Run parameterized SELECT queries and return rows (
query)Execute parameterized INSERT/UPDATE/DELETE statements (
execute)List tables in a schema (
list_tables)Describe table structure including columns, indexes, and constraints (
describe_table)Run DDL migrations inside a transaction (
run_migration)Get execution plans via
EXPLAIN ANALYZE(explain_analyze)Configure via
DB_BRIDGE_*environment variables (DSN, pool size, read-only mode, query timeout, log level)
Provides tools for querying, inspecting, and managing local PostgreSQL databases, including read-only SELECT queries, listing schemas and tables, describing table columns and constraints, and optionally executing write or DDL statements when enabled.
DB Bridge
Local-first PostgreSQL MCP bridge for Private Desk. Query, inspect, and manage a database you already run — without sending that data to a cloud sidecar.
Client / COLP install guide (plain English): CLIENT-README.md.
Build class: UNSIGNED INTERNAL. This tree is not Authenticode-signed. Thumbprint: (none — unsigned).
Setup (installer, pip, uv) may use the network for wheels. The running bridge does not phone home.
Recommended: Windows one-command installer
From a clone of this repository, in PowerShell:
Set-ExecutionPolicy -Scope Process Bypass
.\installer\Install-DbBridge.ps1 -Dsn "postgresql://user:pass@localhost:5432/dbname"Silent / unattended (the UNSIGNED INTERNAL label is still printed):
.\installer\Install-DbBridge.ps1 -Dsn "postgresql://user:pass@localhost:5432/dbname" -QuietDefault location: %LOCALAPPDATA%\AirgapFleet\db-bridge. Dependencies are pinned from uv.lock when uv is on PATH.
See installer/README.md.
Verify
.\scripts\self_test.ps1 -ProtocolOnlyCaveat: protocol-only PASS means MCP initialize and tools/list succeeded. It is not full tool coverage and does not prove a live PostgreSQL connection. The pool is lazy — those calls do not open the database.
A full check needs Postgres and a DSN. Without a DSN it fails on purpose:
.\scripts\self_test.ps1 -Full -Dsn "postgresql://user:pass@localhost:5432/dbname"Uninstall
.\installer\Uninstall-DbBridge.ps1Related MCP server: mcpgov
Advanced: pip / uvx
pip install airgap-db-bridge
# or, no persistent install:
uvx airgap-db-bridgeThen point your MCP client at the airgap-db-bridge executable and set DB_BRIDGE_DSN.
MCP client config
Windows (use the full path to the executable):
{
"mcpServers": {
"database": {
"command": "C:\\Users\\<user>\\AppData\\Local\\AirgapFleet\\db-bridge\\venv\\Scripts\\airgap-db-bridge.exe",
"env": {
"DB_BRIDGE_DSN": "postgresql://user:pass@localhost:5432/db"
}
}
}
}macOS / Linux (if the script is on PATH):
{
"mcpServers": {
"database": {
"command": "airgap-db-bridge",
"env": {
"DB_BRIDGE_DSN": "postgresql://user:pass@localhost:5432/db"
}
}
}
}Configuration
Canonical prefix: DB_BRIDGE_*. Legacy POSTGRES_* and POSTGRESQL_MCP_* names are read only when the canonical variable is unset.
Environment variable | Default | Description |
| required for DB tools | PostgreSQL connection string |
| 10 | Connection pool size (1–100) |
| false | Recorded on the config object |
| 30 | Query timeout in seconds |
| INFO | Structured logs (stderr only) |
Copy .env.example to .env for local development. See AUDIT-NOTES.md.
Available tools
Tool | Description |
| Parameterised SELECT |
| Parameterised INSERT / UPDATE / DELETE |
| Tables in a schema |
| Columns, indexes, constraints |
| DDL statements in a transaction |
|
|
stdio is the supported local MCP transport. Structured logs go to stderr only so stdout stays JSON-RPC clean.
Proof pack
proof-pack/ has the demo checklist, UNSIGNED INTERNAL signing note, egress observation notes, and hash helpers. A full database demo needs Postgres.
This project does not claim Cyber Essentials, ISO 27001, or any other certification.
Development
pip install -e ".[dev]"
uv run pytest -v
uv run ruff check src/postgresql_mcp
uv run mypy src/postgresql_mcp
python scripts/self_test.py --protocol-onlyLicence
MIT
Available Tools
6 toolsdescribe_tableA
Describe a table's structure including columns, indexes, and constraints.
Inputs: table (required), schema. Returns: object
executeB
Execute a parameterized INSERT, UPDATE, or DELETE statement.
Inputs: sql (required), params. Returns: object
explain_analyzeA
Get query execution plan with costs using EXPLAIN ANALYZE.
Inputs: sql (required), params. Returns: object
list_tablesB
List all tables in a schema.
Inputs: schema. Returns: object
queryA
Execute a parameterized SELECT query and return rows.
Inputs: sql (required), params. Returns: object
run_migrationA
Run a database migration (DDL statements) in a transaction.
Inputs: sql (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct role: query for SELECT, execute for DML, run_migration for DDL, explain_analyze for query plans, and list_tables/describe_table for schema inspection. There is no meaningful overlap that would confuse an agent selecting among them.
Most tools follow a clear verb_noun pattern, such as list_tables, describe_table, and run_migration. The bare verb tools query and execute break the pattern slightly, but they are standard database terms and remain predictable in context.
The 6-tool surface is well-scoped for a database bridge: it covers queries, changes, schema introspection, migration, and performance analysis without unnecessary duplication. Each tool serves a meaningful purpose.
The set covers the core lifecycle of database interaction: read, write, schema inspection, DDL changes, and query analysis. Minor gaps exist, such as no explicit transaction control for arbitrary DML batches or no tool for managing connections, but these are reasonable workarounds.
Maintenance
Related MCP Connectors
Managed Postgres MCP: projects, SQL, docs search, and storage buckets via OAuth.
Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseAqualityDmaintenanceA self-hostable PostgreSQL MCP server for exploring database schemas and running guarded read/write queries with selectable access modes (readonly, readwrite, admin), plus a dry-run confirm workflow for safety.141MIT
- FlicenseNot gradedqualityDmaintenanceA production-grade MCP server over Postgres, providing secure data operations with tenant isolation, exact-once mutations, loop-aware rate limiting, and a tamper-evident audit trail.1-
- AlicenseNot gradedqualityDmaintenanceProvides a read-only PostgreSQL MCP server with schema introspection. Enforces least-privilege database roles to prevent any writes, even from malicious SQL.MIT
- AlicenseAqualityBmaintenanceA security-hardened Postgres MCP server that enables LLM agents to run safe, read-only SQL queries with enforcement via SQL-AST inspection and read-only transactions.1MIT