a2db MCP server
✓ 인증됨배치 쿼리와 구조화된 TSV 출력을 통해 AI agent에게 여러 데이터베이스에 대한 안전한 읽기 전용 액세스를 제공합니다.
다른 이름 agentic-eng/a2db
- 스타
- 2
- Tools
- 5
- 다운로드, 30일
- 173
- 최신 버전
- 0.2.1
- 마지막 커밋
- 2026년 4월 13일
- 라이선스
- Apache-2.0
a2db MCP란?
a2db은(는) MCP server입니다. 배치 쿼리와 구조화된 TSV 출력을 통해 AI agent에게 여러 데이터베이스에 대한 안전한 읽기 전용 액세스를 제공합니다. 5개 도구를 제공합니다. 예: login, logout, list_connections.
프로젝트 README에서 생성된 요약
a2db MCP server 정보
a2db는 AI agent에게 PostgreSQL, SQLite, MySQL, Oracle, SQL Server를 포함한 다섯 가지 유형의 데이터베이스에 대한 안전한 읽기 전용 액세스를 제공합니다. 이 서버는 agent가 단일 도구 호출 내에서 여러 개의 이름이 지정된 쿼리를 실행할 수 있도록 하여 단일 쿼리 실행의 비효율성을 해결하도록 설계되었습니다. 이 MCP server는 stdio를 통해 로컬에서 실행되며, 설정 파일을 사용하여 Claude Code, Claude Desktop 또는 Cursor와 같은 클라이언트에 통합할 수 있습니다.
보안은 최우선 과제로, 데이터베이스 사용자가 해당 권한을 가지고 있더라도 SQLGlot AST 파싱을 활용하여 INSERT 또는 DELETE와 같은 모든 쓰기 작업을 차단합니다. 토큰 사용을 최적화하기 위해 서버는 구조화된 JSON 엔벨로프 내에 압축된 TSV 형식으로 데이터를 반환하며, 이는 표준 JSON 행과 비교했을 때 컨텍스트 창 소모를 40-60% 줄일 수 있습니다. 사용자는 CLI를 통해 연결을 관리하거나 --register 플래그를 사용하여 MCP 설정에 미리 등록할 수 있으며, 환경 변수 확장을 사용하여 민감한 자격 증명을 안전하게 보호할 수 있습니다.
활용 사례
- 1배치 데이터베이스 쿼리 실행AI agent는 활성 사용자 및 최근 주문 내역과 같이 서로 관련된 여러 데이터 세트를 단 한 번의 요청으로 가져올 수 있습니다.
- 2LLM 토큰 비용 절감서버는 AI 모델로 전송되는 텍스트 양을 최소화하기 위해 플랫 그리드 형식을 사용합니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
a2db MCP 설치 방법
형식 확인: 2026년 11월 10일Cursor에 추가Goose에 추가Claude Code에 a2db MCP 설치
$ claude mcp add a2db -- uvx a2dbCursor에 a2db MCP 설치
~/.cursor/mcp.json
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db"
]
}
}
}VS Code에 a2db MCP 설치
.vscode/mcp.json
{
"servers": {
"a2db": {
"type": "stdio",
"command": "uvx",
"args": [
"a2db"
]
}
}
}VS Code CLI에 a2db MCP 설치
$ code --add-mcp '{"name":"a2db","type":"stdio","command":"uvx","args":["a2db"]}'Claude Desktop에 a2db MCP 설치
claude_desktop_config.json
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db"
]
}
}
}Codex에 a2db MCP 설치
$ codex mcp add a2db -- uvx a2dbCodex config.toml에 a2db MCP 설치
~/.codex/config.toml
[mcp_servers.a2db] command = "uvx" args = ["a2db"]
Gemini CLI에 a2db MCP 설치
$ gemini mcp add -s user a2db uvx -- a2dbGemini settings.json에 a2db MCP 설치
~/.gemini/settings.json
{
"mcpServers": {
"a2db": {
"command": "uvx",
"args": [
"a2db"
]
}
}
}a2db MCP 도구 5
README에서 감지됨loginlogoutlist_connectionsexecutesearch_objects
| login | — | |
| logout | — | |
| list_connections | — | |
| execute | — | |
| search_objects | — |
구성
DB_PASSWORD
| 이름 | 설명 | 유형 |
|---|---|---|
| DB_PASSWORD | — |
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 이는 보안 감사가 아닙니다. 코드를 직접 읽고 서버에 필요한 최소한의 권한만 부여하십시오. 검사 방식
- 소스 저장소 연결 및 접근 가능agentic-eng/a2db is public and reachablegithub.com/agentic-eng/a2db ↗통과
- 패키지가 이 저장소를 소스로 명시검사되지 않음
- 빌드 출처(Sigstore 증명)Sigstore attestation for a2dbpypi.org/project/a2db/ ↗통과
- 오픈 소스 라이선스 (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-04-13github.com/agentic-eng/a2db ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음No popular package one edit away from a2db통과
- 패키지 및 해당 종속성에 중요한 보안 권고 없음43 resolved dependencies checked; no critical advisoryosv.dev ↗통과
- 모델에 대한 숨겨진 지침 없음5 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨검사되지 않음
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기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"
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 질문
a2db MCP를 Claude Code에 추가하려면 어떻게 하나요?
터미널에서 claude mcp add a2db -- uvx a2db를 실행합니다. 모든 프로젝트에서 사용할 수 있게 하려면 --scope user를 추가합니다.
a2db MCP를 Cursor에 추가하려면 어떻게 하나요?
~/.cursor/mcp.json를 열고 mcpServers 아래에 서버를 추가합니다. 위 설치 섹션에 표시된 Cursor 구성을 사용합니다.
a2db MCP는 어떤 도구를 제공하나요?
5개 도구를 제공합니다. 예: login, logout, list_connections, execute, search_objects.
a2db는 데이터베이스 보안을 어떻게 보장하나요?
SQLGlot AST 파싱을 사용하여 INSERT, UPDATE, DELETE와 같은 모든 쓰기 작업을 차단하므로 쿼리가 읽기 전용으로 유지됩니다.
데이터베이스 자격 증명은 어떻게 처리되나요?
비밀 정보는 ${ENV_VAR} 구문을 사용하여 환경 변수에 보관되며, 연결 시에만 확장되고 평문으로 저장되지 않습니다.
서버가 쿼리 결과로 TSV 형식을 사용하는 이유는 무엇인가요?
TSV는 JSON 행 형식보다 토큰을 40-60% 적게 사용하므로 LLM 컨텍스트 창에 더 효율적입니다.