Dbridge Mcp

io.github.ugurcl由 GitHub 帳號 ugurcl 發布v0.7.1更新於 Nov 3, 2026

Query SQLite, PostgreSQL, and MySQL in plain language - read-only, with column masking and limits.

已驗證STDIO僅桌面資料庫資料與分析

概覽

AI 產生的概覽

唯讀的 MCP 伺服器,讓助理以自然語言瀏覽並查詢 SQLite、PostgreSQL 與 MySQL 資料庫,支援欄位遮罩與列數上限。

可以做什麼
  • 探索結構:列出資料表、檢視欄位、主鍵、外鍵與列數估計、預覽範例列、計算精確列數
  • 查詢資料:執行單一唯讀 SELECT 或 WITH,結果以 JSON、CSV 或 markdown 回傳,或檢視執行計畫與預估成本
  • 分析效能:各欄位基數與空值比例、索引大小與掃描次數、模擬索引測試、最耗時的已記錄語句
  • 檢視安全設定:回報目前生效的列數上限、逾時以及隱藏或遮罩的欄位
  • 以單一 JSON 資源讀取完整結構,並依引導式最佳化提示進行索引調整
適用情境
適合讓助理回答關於真實 SQL 資料庫的問題,或針對索引與慢查詢提供建議,同時不授予寫入權限。適用於你重視的資料上的報表與分析工作,包括生產資料庫,此時內建的防護措施格外重要。
執行需求
透過 npx 或全域 npm 安裝以 stdio 在本機執行,需要 Node.js 22.5 或更新版本。必須提供連線參數:SQLite 檔案路徑,或含憑證的 PostgreSQL、MySQL/MariaDB 連線字串。選用環境變數 DBRIDGE_CONFIG 指向含安全設定的 JSON 檔案,其他限制可用命令列參數或 DBRIDGE_ 開頭的環境變數設定。Windows 上需透過 cmd /c 啟動。
安裝前請注意
連線字串含有資料庫憑證;README 建議以 DBRIDGE_DB_PATH 傳入,避免密碼出現在行程清單中,並建議使用僅具唯讀權限的專用資料庫角色作為真正的安全界線。查詢雖為唯讀且僅限 SELECT/WITH,結果仍會送往模型,應隱藏或遮罩敏感欄位並使用資料表允許清單。選用的稽核日誌會把每次工具呼叫寫入 stderr。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Dbridge Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[dbridge-mcp]

dbridge-mcp

An MCP server that lets an AI agent query a SQL database in plain language — safely and read-only.

[CI] [npm] [node >=22.5] [MIT license]

[dbridge-mcp demo: an AI agent answering a question by querying the database]

The agent discovers the schema on its own (list_tables, describe_table), then writes and runs a SELECT for whatever the user asks. No hand-written endpoint per question.

Works with SQLite, PostgreSQL, and MySQL / MariaDB.

Why

A raw LLM cannot know what is inside your database, and web search cannot reach private data. dbridge gives the model a guarded door to that data: it can read and answer, but it cannot write, drop, or leak the whole table.

Why dbridge and not another database MCP?

There are many database MCP servers. dbridge is built around one idea — you should be able to point an AI at a real database without holding your breath — and that shows up as a combination the single-engine servers don't offer:

  • One server, three engines. SQLite, PostgreSQL, and MySQL/MariaDB behind the same tools and the same config. Switch databases by changing the connection string, not the tooling.
  • Read-only twice over. A SQL guard rejects anything but SELECT/WITH and every query runs inside a database-enforced READ ONLY transaction — so even a query that outsmarts the guard cannot write.
  • Column-level privacy. Hide columns from the model entirely, or mask values (a***@site.com) while keeping them queryable. Most servers expose whatever the connection can see.
  • Blast-radius controls. Row caps enforced over user-supplied LIMITs, per-query timeouts, EXPLAIN-based cost rejection for expensive queries, per-minute rate limits, and a capped connection pool.
  • No native build step. SQLite uses Node's built-in node:sqlite, so npx -y dbridge-mcp works without a compiler toolchain.
  • Performance insight, not just queries. column_stats and index_health give the model real cardinality and index-usage data, and test_index simulates an index with hypopg before anyone builds it — so the model's optimization advice is grounded in the actual database instead of guesswork.

If all you need is "run SQL from my agent", plenty of servers do that. dbridge is for pointing an agent at data you actually care about.

Tools

ToolPurpose
list_tablesList every table in the database.
describe_tableReturn a table's columns, primary key, foreign keys, and row-count estimate.
sample_tablePreview the first rows of a table (json/csv/markdown).
count_rowsReturn the exact row count of a table.
run_queryRun a single read-only SELECT / WITH and return rows as json, csv, or markdown.
explain_queryReturn a query's plan and estimated cost without running it.
column_statsPer-column distinct-value counts and null fractions — is this column selective enough to index?
index_healthList indexes with sizes and scan counts, flagging unused, duplicate, and invalid ones.
test_indexSimulate a CREATE INDEX without building it and report whether the planner would use it (PostgreSQL, via hypopg).
slow_queriesThe most expensive recorded statements with call counts and timings (PostgreSQL pg_stat_statements, MySQL performance_schema).
get_limitsReport the safety limits in effect (caps, timeouts, hidden/masked columns).

Resources

ResourcePurpose
dbridge://schemaThe full schema (every table and its columns) as one JSON document.

Prompts

PromptPurpose
optimizeA guided optimization pass: find slow queries, inspect plans and index health, and validate every index recommendation with test_index before suggesting it.

Requirements

Node.js 22.5+ (SQLite uses the built-in node:sqlite, no native build step).

Install

The published package ships a dbridge-mcp binary, so no clone or build step is needed to use it. Point it at a database with the connection argument:

bash
npx -y dbridge-mcp demo.db                                  # SQLite (file path)npx -y dbridge-mcp "postgresql://user:pass@host:5432/mydb"  # PostgreSQLnpx -y dbridge-mcp "mysql://user:pass@host:3306/mydb"       # MySQL / MariaDB

The database engine is chosen from the connection string: a file path is SQLite, postgres:// / postgresql:// is PostgreSQL, and mysql:// is MySQL/MariaDB.

Or install it once, globally:

bash
npm install -g dbridge-mcpdbridge-mcp "postgresql://user:pass@host:5432/mydb"

MCP clients start the server for you as a subprocess — see the client sections below.

Windows note: MCP clients cannot launch npx directly on Windows because it is a .cmd script. Wrap it with cmd /c — use "command": "cmd" and put "/c", "npx", "-y", "dbridge-mcp", "<connection>" in the args. The examples below use the direct form (macOS/Linux); on Windows add the cmd /c prefix.

Use it in Claude Desktop

Claude Desktop only supports a single global config. Add to claude_desktop_config.json:

json
{  "mcpServers": {    "dbridge": {      "command": "npx",      "args": ["-y", "dbridge-mcp", "postgresql://user:pass@host:5432/mydb"],      "env": { "DBRIDGE_CONFIG": "/absolute/path/to/dbridge.config.json" }    }  }}

For a local SQLite file, replace the connection string with an absolute path to the .db file. Restart Claude Desktop, then ask: "what were the 5 best-selling products last month?"

Use it in Claude Code

Add it to the current project with the CLI:

bash
claude mcp add dbridge --scope project \  -e DBRIDGE_CONFIG=/absolute/path/to/dbridge.config.json \  -- npx -y dbridge-mcp "postgresql://user:pass@host:5432/mydb"

--scope project writes a shareable .mcp.json in the project root; use --scope user for a global server or omit it for a private per-project one. The .mcp.json looks like:

json
{  "mcpServers": {    "dbridge": {      "command": "npx",      "args": ["-y", "dbridge-mcp", "postgresql://user:pass@host:5432/mydb"],      "env": { "DBRIDGE_CONFIG": "/absolute/path/to/dbridge.config.json" }    }  }}

Run claude from that directory; approve the project server once, then check it with /mcp.

Use it in Cursor

Add the same mcpServers block to .cursor/mcp.json in the project root (or ~/.cursor/mcp.json for all projects), enable the server under Settings → MCP, then ask the Agent a question about your data.

Use it in Windsurf

Add the same mcpServers block to ~/.codeium/windsurf/mcp_config.json, then refresh the server list under Settings → Cascade → MCP.

Use it in OpenCode

Add to opencode.json (project root or ~/.config/opencode/opencode.json):

json
{  "$schema": "https://opencode.ai/config.json",  "mcp": {    "dbridge": {      "type": "local",      "command": ["npx", "-y", "dbridge-mcp", "postgresql://user:pass@host:5432/mydb"],      "enabled": true    }  }}

To tune the safety guard, point the server at a config file with the environment block:

json
"environment": { "DBRIDGE_CONFIG": "/absolute/path/to/dbridge.config.json" }

Docker

Build the image and run the server over stdio:

bash
docker build -t dbridge-mcp .docker run --rm -i dbridge-mcp "postgresql://user:pass@host:5432/mydb"

Mount a config file and point DBRIDGE_CONFIG at it:

bash
docker run --rm -i \  -v "$PWD/dbridge.config.json:/config.json:ro" \  -e DBRIDGE_CONFIG=/config.json \  dbridge-mcp "postgresql://user:pass@host:5432/mydb"

Safety

  • The connection is opened read-only. On PostgreSQL and MySQL every query also runs inside a READ ONLY transaction, so writes are rejected by the database itself even if a query slips past the guard.
  • Only SELECT and WITH statements pass; writes, DDL, and data-modifying CTEs are rejected.
  • A single statement per call; the row cap is enforced even when a query supplies its own larger LIMIT (default 1000 rows).
  • Each PostgreSQL and MySQL query is bounded by a per-query timeout (statement_timeout / max_execution_time), so a runaway or expensive query cannot pin the database.
  • System catalogs and credential tables (information_schema, pg_authid, sqlite_master, …) are not queryable; schema discovery goes through the tools.
  • Restricted columns can be hidden entirely: the model cannot see them in the schema, query them, or receive them in results.
  • Tables can be restricted with an allow-list or block-list; blocked tables are invisible and unqueryable.
  • Columns can be masked instead of hidden: they stay visible but values come back partially redacted (e.g. a***@site.com).
  • Expensive queries can be rejected up front by an EXPLAIN cost estimate, and callers can be rate-limited per minute.
  • The connection pool size is capped, so dbridge cannot exhaust the database's connections.

Config

Every setting has three sources, in increasing precedence: a JSON file (DBRIDGE_CONFIG), environment variables, then CLI flags. So you can drop the JSON file entirely and set only what you need:

bash
npx -y dbridge-mcp "postgresql://user:pass@host/db" --max-rows 200 --statement-timeout-ms 3000 --masked-columns email,ibanDBRIDGE_MAX_ROWS=200 DBRIDGE_REQUIRE_SSL=true npx -y dbridge-mcp "postgresql://user:pass@host/db"

Or keep everything in one place: point DBRIDGE_CONFIG at a JSON file (see dbridge.config.example.json for a full template). Every field is optional:

json
{  "maxRows": 500,  "hiddenColumns": ["ssn", "password_hash"],  "maskedColumns": ["iban", { "column": "email", "strategy": "email" }],  "allowedTables": ["products", "sales", "customers"],  "blockedTables": ["employees", "audit_log"],  "statementTimeoutMs": 5000,  "maxCost": 100000,  "rateLimitPerMin": 60,  "maxPoolSize": 5,  "connectionTimeoutMs": 10000,  "requireSsl": true,  "schemas": ["public", "reporting"],  "auditLog": true}
FieldCLI flag / env varDefaultPurpose
maxRows--max-rows / DBRIDGE_MAX_ROWS1000Hard cap on rows returned per query, enforced even over a larger LIMIT.
hiddenColumns--hidden-columns / DBRIDGE_HIDDEN_COLUMNS[]Columns hidden from the schema, queries, and results.
maskedColumns--masked-columns / DBRIDGE_MASKED_COLUMNS[]Columns whose values are redacted in results (see below).
maxCellChars--max-cell-chars / DBRIDGE_MAX_CELL_CHARS0Truncate any string cell longer than this; 0 disables.
maxResultBytes--max-result-bytes / DBRIDGE_MAX_RESULT_BYTES0Cap the total serialized result size, dropping trailing rows; 0 disables.
allowedTables--allowed-tables / DBRIDGE_ALLOWED_TABLES[]If non-empty, only these tables are exposed.
blockedTables--blocked-tables / DBRIDGE_BLOCKED_TABLES[]Tables that are always hidden and unqueryable.
statementTimeoutMs--statement-timeout-ms / DBRIDGE_STATEMENT_TIMEOUT_MS10000Per-query timeout (PostgreSQL statement_timeout, MySQL max_execution_time); 0 disables.
maxCost--max-cost / DBRIDGE_MAX_COST0Reject queries whose EXPLAIN cost estimate exceeds this (PostgreSQL/MySQL); 0 disables.
rateLimitPerMin--rate-limit-per-min / DBRIDGE_RATE_LIMIT_PER_MIN0Max query-executing tool calls per minute; 0 disables.
maxPoolSize--max-pool-size / DBRIDGE_MAX_POOL_SIZE5Maximum pooled connections (PostgreSQL/MySQL).
connectionTimeoutMs--connection-timeout-ms / DBRIDGE_CONNECTION_TIMEOUT_MS10000How long to wait for a connection (PostgreSQL/MySQL).
requireSsl--require-ssl / DBRIDGE_REQUIRE_SSLfalseRequire a verified TLS connection (PostgreSQL/MySQL).
schemas--schemas / DBRIDGE_SCHEMAS["public"]PostgreSQL-only: schemas to expose; multiple schemas yield schema.table names.
auditLog--audit-log / DBRIDGE_AUDIT_LOGfalseLog every tool call (query, rows, duration, errors) as JSON to stderr.

List values on the command line or in env vars are comma-separated (--allowed-tables products,sales).

Engine note: statementTimeoutMs, maxCost, maxPoolSize, connectionTimeoutMs, requireSsl, and schemas apply to the networked engines (PostgreSQL/MySQL). SQLite is a local file, so it ignores them; the row cap, column/table access control, and masking apply to every engine.

Column masking

maskedColumns keeps a column visible but redacts its values. Each entry is either a column name (defaults to the partial strategy) or an object { "column": ..., "strategy": ..., "keep": ... }:

StrategyExample inputOutput
partial (default)TR120000123456**********3456 (keeps the last keep, default 4)
email[email protected]a***@site.com
fullanything***

Unlike hiddenColumns, a masked column can still be used in WHERE/GROUP BY, so use hiddenColumns for true secrets and maskedColumns for values that should be recognizable but not exposed.

Output formats

run_query and sample_table take an optional format argument: json (default, full result object), csv, or markdown. CSV and Markdown return a compact table prefixed with a short rows: N · Nms header — handy for fewer tokens and readable output. Combine with maxCellChars and maxResultBytes to keep large results in check.

Running against a production database

  • Pass the connection string via the DBRIDGE_DB_PATH environment variable instead of the command line, so the password does not appear in the process list.
  • Prefer a dedicated database role with read-only grants on only the tables you want exposed — that is the real security boundary; the guard is defense in depth.
  • Set a conservative statementTimeoutMs, maxRows, and maxCost, and use allowedTables to expose only reporting tables.

Local development

To hack on dbridge itself, clone the repo and build from source:

bash
npm installnpm run buildnpm run seed        # creates demo.db (a small store: products, customers, sales)node dist/index.js demo.db

Try it with the MCP Inspector

bash
npm run inspect

Then call the tools from the Inspector UI. No LLM or API key needed.

Tests

bash
npm test

Changelog

See CHANGELOG.md.

License

MIT

來源:README.md,提交 f2a8779

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.7.1最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。