The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the A2db listing page.
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
Quick Start · MCP Tools · Security · Comparison · Setup
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:
.mcp.json with --register, agent queries immediatelypip install a2db and you're done${DB_PASSWORD} in DSNs, expanded only at connection time| Database | Driver | Async |
|---|---|---|
| PostgreSQL | asyncpg | native |
| SQLite | aiosqlite | native |
| MySQL / MariaDB | mysql-connector-python | wrapped |
| Oracle | oracledb | wrapped |
| SQL Server | pymssql | wrapped |
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.
| Tool | Description |
|---|---|
login | Save a connection — validates by connecting first |
logout | Remove a saved connection |
list_connections | List connections (no secrets exposed) |
execute | Run named batch queries with pagination |
search_objects | Explore schema — tables, columns, with detail levels |
execute — the core toolNamed 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.
When a query fails with a column error, a2db enriches the message:
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.
Every query is parsed by SQLGlot before execution:
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.
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.list_connections shows project/env/db and database type, never DSNs or passwordsa2db 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.
| Feature | a2db | DBHub | Google Toolbox | PGMCP | Supabase MCP |
|---|---|---|---|---|---|
| Databases | 5 (PG, SQLite, MySQL, Oracle, MSSQL) | 5 (PG, MySQL, MSSQL, MariaDB, SQLite) | 40+ (cloud + OSS) | PG only | PG (Supabase) |
| Batch queries | Named dict + list | Semicolon-separated | No | No | No |
| Default connection | Set once, use for all | Per-query | N/A | Single DB | Single project |
| Read-only | SQLGlot AST (enforced) | Keyword check (config) | Hint/annotation | Read-only tx + regex | Config flag |
| Write support | Planned (per-connection) | Config flag | Via tool definition | No | Config flag |
| Output | JSON + TSV data | Structured text | MCP protocol | Table / JSON / CSV | JSON |
| Schema discovery | 3 detail levels | Dedicated tool | Prebuilt tools | Via NL-to-SQL | Dedicated tools |
| Pre-configured | --register in MCP config | Config file | YAML config | Env var | Cloud-managed |
| Credentials | ${ENV_VAR} in DSN | DSN strings | Env vars + GCP IAM | Env var | OAuth 2.1 |
| Drivers bundled | All included | All included | Varies | Built-in | Managed |
| CLI | Yes | No | Yes | Yes | No |
| Error context | Column suggestions + types | No | No | No | No |
| License | Apache 2.0 | MIT | Apache 2.0 | Apache 2.0 | Apache 2.0 |
When to use what:
Secrets are injected as environment variables at runtime — never baked into the image.
Apache 2.0
🗄️ Agent-first database access since 2025.
Built by Denis Tomilin