A2db

by agentic-eng

269 downloads
Not rated
GitHub

Description

## Why a2db? - **Batch queries** — multiple named queries in a single tool call - **Pre-configured connections** — define databases in .mcp.json, agent queries immediately - **Default connection** — set once, use across all queries in a batch - **Read-only enforced** — SQLGlot…

About

## Why a2db? - **Batch queries** — multiple named queries in a single tool call - **Pre-configured connections** — define databases in .mcp.json, agent queries immediately - **Default connection** — set once, use across all queries in a batch - **Read-only enforced** — SQLGlot AST parsing blocks writes at the syntax…

Details

Author
agentic-eng
Downloads
269
Categories
Database, Other, AI

- Batch queries with multiple named queries in one tool call
- Pre-configured database connections via .mcp.json
- Default connection for all queries in a batch
- Read-only enforced via SQLGlot AST parsing
- Clean JSON output with TSV data and per-query timing
- Supports 5 databases with all drivers bundled
- Error context with column suggestions and types

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name A2db
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install with pip install a2db, then add to your MCP config using the command uvx with arguments to register one or more database connections. Alternatively, let the agent call login on demand — no pre-configuration is required.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "a2db": {
            "a2db": {
                "command": "uvx",
                "args": [
                    "a2db-mcp"
                ]
            }
        }
    }
}

McpServers

{
    "a2db": {
        "command": "uvx",
        "args": [
            "a2db-mcp"
        ]
    }
}

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

Agent: "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"

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 bundledpip install a2dband you're done
- Secrets stay in env${DB_PASSWORD}in DSNs, expanded only at connection time

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 callsloginon demand):

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" } } } }
{ "args": [ "a2db-mcp", "--register", "myapp/prod/main", "postgresql://user:${DB_PASSWORD}@host/maindb", "--register", "myapp/prod/analytics", "postgresql://user:${DB_PASSWORD}@host/analytics" ] }

--registerpre-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.

# 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

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"} } }
{ "connection": {"project": "myapp", "env": "prod", "db": "main"}, "queries": [ {"sql": "SELECT COUNT() AS cnt FROM users"}, {"sql": "SELECT AVG(total) AS avg_order FROM orders"} ] }
{ "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::textcasts needed — integers, floats, timestamps, arrays, NULLs all work natively.

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)

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 uses40-60% fewer tokensthan JSON row format. The structured JSON envelope still gives you metadata (row count, truncation status) — only the row payload is TSV.

Setformat="json"if you need full structured output with column names on every row.

Every query is parsed bySQLGlotbefore 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 supportis implemented in the core but not yet exposed via MCP. Planned: per-connection write permissions, explicitly enabled by the human operator — not the agent. SeeTODO.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.
- No secrets in list outputlist_connectionsshows project/env/db and database type, never DSNs or passwords
- Connection files are local to your machine and outside any repository

a2db currently runs as alocal 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.

- 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)

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)
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.

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"
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

🗄️ Agent-first database access since 2025.

Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite

A single-binary MCP server for MySQL, MariaDB, PostgreSQL, and SQLite

A Model Context Protocol (MCP) server that provides multi-database query execution capabilities with support for SQLite, PostgreSQL, and MySQL databases. Includes a built-in Web UI for managing database connections.

Update various databases (PostgreSQL, MySQL, MongoDB, SQLite) using data from CSV and Excel files.

Enables AI assistants to interact with various databases through JDBC connections.

Production-grade Model Context Protocol (MCP) server for unified SQL database access. Connect multiple databases through a single MCP server with schema discovery, relationship mapping, caching, and safety controls.

Provides database access for SQLite, SQL Server, PostgreSQL, and MySQL.

Multi-database analysis MCP server (PostgreSQL, MySQL, SQLite). Inspects schemas, detects index problems, analyzes table bloat, and explains query plans for actionable database optimization.

A lightweight MCP server for any database with a JDBC driver. Built with Quarkus and requires Java 21+.

An MCP server that provides AI assistants with structured access to multiple databases simultaneously.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.