DB MCP Server

io.github.stucchi由 GitHub 帳號 stucchi 發布v1.2.1更新於 Oct 24, 2026

Database MCP server for MySQL, PostgreSQL, MongoDB, and SQLite with SSH tunneling support.

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理查詢 MySQL、PostgreSQL、MongoDB 或 SQLite 資料庫,並在讀寫模式下修改資料,可選擇經 SSH 通道連線。

可以做什麼
在 MySQL、PostgreSQL 和 SQLite 上執行唯讀 SQL 查詢並檢視結果,或在 MongoDB 集合中尋找文件並執行彙總管線(唯讀模式下封鎖 $out/$merge)。列出資料表或集合,並描述資料表結構或集合統計資訊。顯示連線狀態與資訊。啟用讀寫模式後可執行 INSERT、UPDATE、DELETE 等寫入 SQL。MySQL 和 PostgreSQL 可經 SSH 跳板主機連線,遠端 SQLite 檔案會先透過 SFTP 下載再查詢。
適用情境
適合讓助理探查資料庫結構、依據即時資料回答問題,或在不另開用戶端的情況下做受控的資料修改。適用於本機桌面環境,包括只能透過跳板主機存取的資料庫。
執行需求
以 Python 套件形式透過 uvx 在本機執行,需要 Python/uv 執行環境。每個執行個體連接一個資料庫。需設定 DB_TYPE 和 DB_DATABASE,並視需要設定 DB_HOST、DB_PORT、DB_USER;MySQL 和 PostgreSQL 需要 DB_PASSWORD,MongoDB 需要 DB_URL,SQLite 需要 DB_PATH。使用 SSH 通道需設定 SSH_HOST 並提供 SSH_KEY 或 SSH_PASSWORD。需要能存取資料庫或跳板主機的網路。
安裝前請注意
資料庫憑證透過環境變數傳入,包括 DB_PASSWORD、DB_URL 和 SSH_PASSWORD,以及透過 SSH_KEY 指定 SSH 私鑰路徑。預設模式為唯讀,但將 DB_MODE 設為 read-write 後,execute 工具可執行 INSERT、UPDATE 和 DELETE;SQLite 經 SSH 時,變更會在關閉時上傳回遠端檔案。建議使用最小權限帳號,非必要不要指向正式環境資料。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

db-mcp-server

MCP server for MySQL, PostgreSQL, MongoDB, and SQLite databases. One instance per database, no Docker required.

Installation

bash
uvx db-mcp-server

Configuration

Configure via environment variables. Each instance connects to a single database.

MySQL

VariableRequiredDefaultDescription
DB_TYPEYes—mysql
DB_DATABASEYes—Database name
DB_PASSWORDYes—Password
DB_HOSTNolocalhostHost
DB_PORTNo3306Port
DB_USERNorootUser
DB_MODENoread-onlyread-only or read-write

PostgreSQL

VariableRequiredDefaultDescription
DB_TYPEYes—postgresql
DB_DATABASEYes—Database name
DB_PASSWORDYes—Password
DB_HOSTNolocalhostHost
DB_PORTNo5432Port
DB_USERNopostgresUser
DB_MODENoread-onlyread-only or read-write

MongoDB

VariableRequiredDefaultDescription
DB_TYPEYes—mongodb
DB_DATABASEYes—Database name
DB_URLYes—Connection URL (mongodb://...)
DB_MODENoread-onlyread-only or read-write

SQLite

VariableRequiredDefaultDescription
DB_TYPEYes—sqlite
DB_PATHYes—Path to .db file (local or remote with SSH)
DB_DATABASENofilenameDisplay name
DB_MODENoread-onlyread-only or read-write

SSH Tunnel (MySQL / PostgreSQL)

Optionally connect through an SSH bastion host. Set SSH_HOST to activate.

For SQLite over SSH, the remote .db file is downloaded via SFTP before querying. In read-write mode, changes are uploaded back on shutdown.

VariableRequiredDefaultDescription
SSH_HOSTNo—SSH bastion host (activates tunneling)
SSH_PORTNo22SSH port
SSH_USERNoCurrent OS userSSH username
SSH_KEYNo—Path to private key (~/.ssh/id_rsa)
SSH_PASSWORDNo—SSH password (if no key)

At least one of SSH_KEY or SSH_PASSWORD is required when SSH_HOST is set. SSH tunneling is not supported for MongoDB.

Usage in .mcp.json

SQLite (local)

json
{  "mcpServers": {    "db-local": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": {        "DB_TYPE": "sqlite",        "DB_PATH": "/path/to/database.db"      }    }  }}

SQLite over SSH

json
{  "mcpServers": {    "db-remote": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": {        "DB_TYPE": "sqlite",        "DB_PATH": "/remote/path/to/database.db",        "SSH_HOST": "server.example.com",        "SSH_USER": "deploy",        "SSH_KEY": "~/.ssh/id_rsa"      }    }  }}
json
{  "mcpServers": {    "db-prod": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": {        "DB_TYPE": "mysql",        "DB_MODE": "read-only",        "DB_HOST": "db.example.com",        "DB_PORT": "3306",        "DB_USER": "root",        "DB_PASSWORD": "secret",        "DB_DATABASE": "myapp"      }    }  }}

With SSH tunnel

json
{  "mcpServers": {    "db-behind-bastion": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": {        "DB_TYPE": "postgresql",        "DB_HOST": "10.0.0.5",        "DB_PORT": "5432",        "DB_USER": "postgres",        "DB_PASSWORD": "secret",        "DB_DATABASE": "myapp",        "SSH_HOST": "bastion.example.com",        "SSH_USER": "deploy",        "SSH_KEY": "~/.ssh/id_rsa"      }    }  }}

For multiple databases, add multiple instances:

json
{  "mcpServers": {    "db-prod": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": { "DB_TYPE": "mysql", "DB_DATABASE": "prod", "..." : "..." }    },    "db-analytics": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": { "DB_TYPE": "postgresql", "DB_DATABASE": "analytics", "..." : "..." }    },    "db-staging": {      "command": "uvx",      "args": ["db-mcp-server"],      "env": { "DB_TYPE": "mongodb", "DB_DATABASE": "staging", "..." : "..." }    }  }}

Tools

MySQL

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)
  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write
  • describe — Describe table structure
  • list_tables — List all tables
  • status — Show connection info

PostgreSQL

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)
  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write
  • describe — Describe table structure (column info from information_schema)
  • list_tables — List all tables in the public schema
  • status — Show connection info

SQLite

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)
  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write
  • describe — Describe table structure (PRAGMA table_info)
  • list_tables — List all tables
  • status — Show connection info

MongoDB

  • query — Find documents in a collection
  • describe — Collection stats ($collStats)
  • list_collections — List all collections
  • aggregate — Execute aggregation pipelines ($out/$merge blocked on read-only)
  • status — Show connection info

License

MIT

來源:README.md,提交 c45f307

工具

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

版本歷史

1
  1. v1.2.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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