a2db MCP server
✓ VerifiziertErmöglicht KI-Agenten sicheren Read-only-Zugriff auf mehrere Datenbanken mittels Batch-Queries und strukturiertem TSV-Output.
Auch bekannt als agentic-eng/a2db
- Stars
- 2
- Tools
- 5
- Downloads, 30 Tage
- 173
- Neueste Version
- 0.2.1
- Letzter Commit
- 13. Apr. 2026
- Lizenz
- Apache-2.0
Was ist a2db MCP?
a2db ist ein MCP server. Ermöglicht KI-Agenten sicheren Read-only-Zugriff auf mehrere Datenbanken mittels Batch-Queries und strukturiertem TSV-Output. Er stellt 5 Tools bereit, etwa login, logout, list_connections.
Zusammenfassung generiert aus dem README des Projekts
Über a2db MCP server
a2db bietet KI-Agenten sicheren, Read-only-Zugriff auf fünf verschiedene Datenbanktypen, darunter PostgreSQL, SQLite, MySQL, Oracle und SQL Server. Es wurde entwickelt, um die Ineffizienz von Single-Query-Ausführungen zu beheben, indem es Agenten ermöglicht, mehrere benannte Queries in einem einzigen Tool-Call auszuführen. Der Server läuft lokal via stdio und kann über eine Config-Datei in Clients wie Claude Code, Claude Desktop oder Cursor integriert werden.
Sicherheit steht an erster Stelle: Durch SQLGlot AST Parsing werden alle Schreiboperationen wie INSERT oder DELETE blockiert, selbst wenn der Datenbank-User über entsprechende Berechtigungen verfügt. Um den Token-Verbrauch zu optimieren, liefert der Server die Daten in einem kompakten TSV-Format innerhalb eines strukturierten JSON-Envelopes zurück. Dies kann den Verbrauch des Context Windows im Vergleich zu Standard-JSON-Zeilen um 40-60% reduzieren. Nutzer können Verbindungen über ein CLI verwalten oder sie mit dem --register Flag vorab in ihrer MCP-Konfiguration registrieren, während sensible Credentials durch die Nutzung von Umgebungsvariablen geschützt bleiben.
Was du damit machen kannst
- 1Batch-Datenbank-Queries ausführenEin KI-Agent kann mehrere zusammenhängende Datensätze, wie etwa aktive Nutzer und deren letzte Bestellungen, in einer einzigen Anfrage abrufen.
- 2LLM-Token-Kosten senkenDer Server nutzt ein flaches Grid-Format, um die Menge des an das KI-Modell gesendeten Textes zu minimieren.
Geschrieben aus dem README des Projekts. Jeder Use Case wurde gegen ein Zitat daraus geprüft.
So installierst du a2db MCP
Formate geprüft am 10. Nov. 2026Zu Cursor hinzufügenZu Goose hinzufügena2db MCP in Claude Code installieren
$ claude mcp add a2db -- uvx a2dba2db MCP in Cursor installieren
~/.cursor/mcp.json
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db"
]
}
}
}a2db MCP in VS Code installieren
.vscode/mcp.json
{
"servers": {
"a2db": {
"type": "stdio",
"command": "uvx",
"args": [
"a2db"
]
}
}
}a2db MCP in VS Code CLI installieren
$ code --add-mcp '{"name":"a2db","type":"stdio","command":"uvx","args":["a2db"]}'a2db MCP in Claude Desktop installieren
claude_desktop_config.json
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db"
]
}
}
}a2db MCP in Codex installieren
$ codex mcp add a2db -- uvx a2dba2db MCP in Codex config.toml installieren
~/.codex/config.toml
[mcp_servers.a2db] command = "uvx" args = ["a2db"]
a2db MCP in Gemini CLI installieren
$ gemini mcp add -s user a2db uvx -- a2dba2db MCP in Gemini settings.json installieren
~/.gemini/settings.json
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db"
]
}
}
}a2db MCP tools 5
Erkannt aus dem READMEloginlogoutlist_connectionsexecutesearch_objects
| login | — | |
| logout | — | |
| list_connections | — | |
| execute | — | |
| search_objects | — |
Konfiguration
DB_PASSWORD
| Name | Beschreibung | Typ |
|---|---|---|
| DB_PASSWORD | — |
Automatisierte Checks
Geluften am 14. Nov. 2026Vollständiger Bericht →Unsere automatisierten Checks bestanden. Das ist kein Security-Audit: Lies den Code und gib dem Server nur den minimal notwendigen Zugriff. Wie die Checks funktionieren
- Source Repository verknüpft und erreichbaragentic-eng/a2db is public and reachablegithub.com/agentic-eng/a2db ↗Bestanden
- Paket nennt dieses Repository als QuelleNicht geprüft
- Build-Provenienz (Sigstore-Attestierung)Sigstore attestation for a2dbpypi.org/project/a2db/ ↗Bestanden
- Open Source Lizenz (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗Bestanden
- Commit oder Release im letzten JahrLast commit or release 2026-04-13github.com/agentic-eng/a2db ↗Bestanden
- OpenSSF ScorecardNicht geprüft
- Package-Name ähnelt keinem populären PackageNo popular package one edit away from a2dbBestanden
- Keine kritischen Advisories im Paket oder seinen Abhängigkeiten43 resolved dependencies checked; no critical advisoryosv.dev ↗Bestanden
- Keine versteckten Anweisungen an das Modell5 tool descriptions and the README read; no override phrases, credential paths or hidden charactersBestanden
- Destruktive Tools sind markiertNicht geprüft
- Remote-Endpoint beantwortet den MCP-HandshakeNicht geprüft
README
Auf GitHub ansehenAgent: "Show me active users and their recent orders"
↓
a2db execute → 2 queries, 1 call, structured results
↓
Agent: "Got it — 847 active users, avg order $42.50"
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
| Database | Driver | Async |
|---|---|---|
| PostgreSQL | asyncpg | native |
| SQLite | aiosqlite | native |
| MySQL / MariaDB | mysql-connector-python | wrapped |
| Oracle | oracledb | wrapped |
| SQL Server | pymssql | wrapped |
Quick Start
pip install a2db
As an MCP Server (recommended)
Claude Code (with pre-configured connection):
claude mcp add -s user a2db -- a2db-mcp \
--register myapp/prod/main 'postgresql://user:${DB_PASSWORD}@host/mydb'
Claude Code (minimal — agent calls login on demand):
claude mcp add -s user a2db -- a2db-mcp
Claude Desktop / Cursor / any MCP client (.mcp.json):
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db-mcp",
"--register", "myapp/prod/main", "postgresql://user:${DB_PASSWORD}@host/mydb"
],
"env": {
"DB_PASSWORD": "your-password-here"
}
}
}
}
Multiple databases:
{
"args": [
"a2db-mcp",
"--register", "myapp/prod/main", "postgresql://user:${DB_PASSWORD}@host/maindb",
"--register", "myapp/prod/analytics", "postgresql://user:${DB_PASSWORD}@host/analytics"
]
}
--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
# Save a connection (validates immediately)
a2db login -p myapp -e prod -d main 'postgresql://user:${DB_PASSWORD}@localhost/mydb'
# Query
a2db query -p myapp -e prod -d main "SELECT * FROM users LIMIT 10"
# JSON output
a2db query -p myapp -e prod -d main -f json "SELECT * FROM users LIMIT 10"
# Explore schema
a2db schema -p myapp -e prod -d main tables
a2db schema -p myapp -e prod -d main columns -t users
# List / remove connections
a2db connections
a2db logout -p myapp -e prod -d main
MCP Tools
| 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 tool
Named dict with default connection (preferred):
{
"connection": {"project": "myapp", "env": "prod", "db": "main"},
"queries": {
"active_users": {"sql": "SELECT id, name FROM users WHERE active = true"},
"recent_orders": {"sql": "SELECT id, total FROM orders ORDER BY created_at DESC LIMIT 5"}
}
}
List format (auto-named q1, q2, ...):
{
"connection": {"project": "myapp", "env": "prod", "db": "main"},
"queries": [
{"sql": "SELECT COUNT(*) AS cnt FROM users"},
{"sql": "SELECT AVG(total) AS avg_order FROM orders"}
]
}
Response (TSV format — default):
{
"active_users": {
"data": "id\tname\n1\tAlice\n2\tBob\n3\tCharlie",
"rows": 3,
"truncated": false,
"time_ms": 12
},
"recent_orders": {
"data": "id\ttotal\n501\t129.00\n500\t49.99",
"rows": 2,
"truncated": false,
"time_ms": 8
}
}
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:
column "nme" does not exist
Did you mean: name?
Available columns: id (integer), name (text), email (text), active (integer)
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
| 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:
- 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)
pip install a2db
# CLI
a2db login -p myapp -e dev -d main 'postgresql://user:pass@localhost/mydb'
# Or add as MCP server (see Quick Start)
Docker
FROM python:3.12-slim
RUN pip install a2db
CMD ["a2db-mcp", "--register", "myapp/prod/main", "postgresql://user:${DB_PASSWORD}@host/mydb"]
docker run -e DB_PASSWORD=secret -i my-a2db-image
Secrets are injected as environment variables at runtime — never baked into the image.
CI / Automation
pip install a2db
# Pre-configured — no login needed
a2db-mcp --register myapp/ci/main "postgresql://ci_user:${CI_DB_PASSWORD}@db-host/mydb"
# Or use CLI directly
a2db login -p myapp -e ci -d main "postgresql://ci_user:${CI_DB_PASSWORD}@db-host/mydb"
a2db query -p myapp -e ci -d main "SELECT COUNT(*) FROM migrations"
Development
make bootstrap # Install deps + hooks
make check # Lint + test + security (full gate)
make test # Tests with coverage (90% minimum)
make lint # Lint only (never modifies files)
make fix # Auto-fix + lint
License
Apache 2.0
a2db MCP Fragen
Wie füge ich a2db MCP zu Claude Code hinzu?
Führe claude mcp add a2db -- uvx a2db in deinem Terminal aus. Füge --scope user hinzu, damit der Server in jedem Projekt verfügbar ist.
Wie füge ich a2db MCP zu Cursor hinzu?
Öffne ~/.cursor/mcp.json und füge den Server unter mcpServers hinzu, mit der Cursor-Config aus dem Installationsabschnitt oben.
Welche Tools bietet a2db MCP?
Er stellt 5 Tools bereit, darunter login, logout, list_connections, execute, search_objects.
Wie gewährleistet a2db die Datenbank-Sicherheit?
Es nutzt SQLGlot AST Parsing, um alle Schreiboperationen wie INSERT, UPDATE und DELETE zu blockieren, sodass Queries ausschließlich Read-only bleiben.
Wie werden Datenbank-Credentials gehandhabt?
Secrets werden über Umgebungsvariablen mit der ${ENV_VAR}-Syntax verwaltet und erst zum Zeitpunkt der Verbindung aufgelöst; sie werden niemals im Klartext gespeichert.
Warum nutzt der Server das TSV-Format für Query-Ergebnisse?
TSV verbraucht 40-60% weniger Tokens als das JSON-Zeilenformat, was die Effizienz für die Context Windows von LLMs deutlich steigert.