
A2db
io.github.agentic-engPublished by GitHub account agentic-engv0.2.1Updated Oct 27, 2026
Safe, read-only database access for AI agents. 5 databases, batch queries, SQLGlot.
Overview
A2db gives an AI assistant safe, read-only SQL access to PostgreSQL, SQLite, MySQL/MariaDB, Oracle and SQL Server, running several named queries in one call.
- What you can do
- Run named batch queries against a chosen connection, with pagination and compact TSV or JSON results
- Explore schemas: list tables and columns with detail levels
- Manage saved connections: add one (validated by connecting first), list them without secrets, remove them
- Pre-register connections at startup so the assistant can query immediately
- Use the same tooling from a command line for ad-hoc queries and schema inspection
- When to use it
- Useful when an assistant should answer questions from one or more relational databases without being able to change them, especially when several queries are needed per turn or connections should be set up once instead of repeated on every call.
- Requirements
- A local Python install of the a2db package (pip install a2db), launched as a stdio process by the MCP client. Database DSNs for each connection, with passwords referenced as environment variables such as DB_PASSWORD and expanded at connection time. Network access to the database hosts.
Installation
In SourceWeft
- Open A2db in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
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
Source: README.md at commit 3c33b3e
Tools
0Version history
1- v0.2.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts
