
A2db
io.github.agentic-eng由 GitHub 帳號 agentic-eng 發布v0.2.1更新於 Oct 27, 2026
Safe, read-only database access for AI agents. 5 databases, batch queries, SQLGlot.
概覽
A2db 讓 AI 助理以唯讀方式安全存取 PostgreSQL、SQLite、MySQL/MariaDB、Oracle 與 SQL Server,並能在一次呼叫中執行多條具名查詢。
- 可以做什麼
- 對指定連線執行批次具名查詢,支援分頁,回傳精簡的 TSV 或 JSON 結果
- 瀏覽資料庫結構:依詳細程度列出資料表與欄位
- 管理已儲存的連線:新增(先連線驗證)、列出(不揭露機密)、移除
- 啟動時預先註冊連線,助理可立即查詢
- 也可透過命令列執行臨時查詢與檢視結構
- 適用情境
- 適合讓助理根據一個或多個關聯式資料庫回答問題,同時不允許它修改資料;尤其適用於每輪需要多條查詢,或希望連線只設定一次而不必每次呼叫重複填寫的情況。
- 執行需求
- 本機安裝 Python 套件 a2db(pip install a2db),由 MCP 用戶端以 stdio 程序啟動。需要每個連線的資料庫 DSN,密碼以環境變數形式引用(例如 DB_PASSWORD),於建立連線時才展開。需要能存取資料庫主機的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 A2db,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
🗄️ a2db
Agent-to-Database
Give AI agents safe, read-only access to your databases. One call, multiple queries, clean results.
5 databases · batch queries · pre-configured connections · SQLGlot read-only
[PyPI] [Python versions] [License] [CI] [MCP Registry]
Quick Start · MCP Tools · Security · Comparison · Setup
Why a2db?
Most database MCP servers make you run one query at a time, repeat connection details on every call, and return results double-encoded inside JSON strings. a2db fixes all of that:
- Pre-configured connections — define databases in
.mcp.jsonwith--register, agent queries immediately - Batch queries — run multiple named queries in a single tool call
- Default connection — set connection once, use it across all queries in a batch
- Clean output — structured JSON envelope with compact TSV data and per-query timing (see why TSV?)
- Read-only enforced — SQLGlot AST parsing blocks all write operations
- All drivers bundled —
pip install a2dband you're done - Secrets stay in env —
${DB_PASSWORD}in DSNs, expanded only at connection time
Supported Databases
Quick Start
As an MCP Server (recommended)
Claude Code (with pre-configured connection):
Claude Code (minimal — agent calls login on demand):
Claude Desktop / Cursor / any MCP client (.mcp.json):
Multiple databases:
--register pre-registers connections at server startup — the agent can query immediately. Passwords use ${ENV_VAR} syntax and are expanded at connection time, never stored in plaintext.
As a CLI
MCP Tools
execute — the core tool
Named dict with default connection (preferred):
List format (auto-named q1, q2, ...):
Response (TSV format — default):
No ::text casts needed — integers, floats, timestamps, arrays, NULLs all work natively.
Error context
When a query fails with a column error, a2db enriches the message:
Why TSV?
LLM context windows are expensive. JSON row data is verbose — every row repeats every column name, adds braces, commas, and quotes. TSV is a flat grid: one header row, then just values separated by tabs.
For a 100-row, 5-column result set, TSV typically uses 40-60% fewer tokens than JSON row format. The structured JSON envelope still gives you metadata (row count, truncation status) — only the row payload is TSV.
Set format="json" if you need full structured output with column names on every row.
Security
Read-Only Enforcement
Every query is parsed by SQLGlot before execution:
- Blocked: INSERT, UPDATE, DELETE, DROP, TRUNCATE, ALTER, CREATE, GRANT, REVOKE
- Bypass-resistant: multi-statement attacks and comment-wrapped writes are caught at the AST level, not just keyword matching
- Allowed: SELECT, UNION, EXPLAIN, SHOW, DESCRIBE, PRAGMA
This is defense-in-depth — you should also use a read-only database user, but a2db won't let writes through even if the user has write permissions.
Write support is implemented in the core but not yet exposed via MCP. Planned: per-connection write permissions, explicitly enabled by the human operator — not the agent. See TODO.md.
Credential Storage
Connections are saved in ~/.config/a2db/connections/ as TOML files.
${DB_PASSWORD}syntax — environment variable references are stored literally and expanded only at connection time. Secrets stay in your environment, not on disk.- No secrets in list output —
list_connectionsshows project/env/db and database type, never DSNs or passwords - Connection files are local to your machine and outside any repository
Deployment Scope
a2db currently runs as a local stdio MCP server. It inherits environment variables from the process that launches it (your shell, Claude Code, Docker). This is the standard model for local MCP servers — the same approach used by DBHub, Google Toolbox, and others.
Planned: remote HTTP transport with OAuth 2.1 per the MCP spec. For now, if running in Docker, inject secrets via environment variables at container runtime.
Comparison
When to use what:
- a2db — multi-DB batch queries with clean output, agent-first design, fast setup
- DBHub — custom tools via TOML config, web workbench UI
- Google Toolbox — GCP ecosystem, IAM integration, 40+ sources
- PGMCP — natural-language-to-SQL for PostgreSQL (requires OpenAI key)
- Supabase MCP — full Supabase platform management (edge functions, branching, storage)
Setup by Environment
Local (macOS / Linux)
Docker
Secrets are injected as environment variables at runtime — never baked into the image.
CI / Automation
Development
License
Apache 2.0
🗄️ Agent-first database access since 2025.
Built by Denis Tomilin
來源:README.md,提交 3c33b3e
工具
0版本歷史
1- v0.2.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
