Safedb MCP server
io.github.narekmalk/safedb-mcp·v0.5.0·8 starsA secure MCP server that lets AI agents query databases safely.
8 stars38 downloads/wk
Reviews
Write oneNobody has reviewed Safedb yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Safedb tools (6, 2 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
describe_tableDescribe columns for an allowed table and show configured masks.
explain_querywrite actionRun a guarded EXPLAIN SELECT query against allowed tables.
get_safedb_policyReturn the effective SafeDB safety policy without secrets.
list_schemasList database schemas allowed by the SafeDB policy.
list_tablesList allowed tables in an allowed schema.
run_readonly_querywrite actionRun a guarded read-only SELECT query against allowed tables.
Public scan report
scanner v0.1.9 · 2026-09-27 · same rubric, same numbers if you re-run it
- Code scan39 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitystatic API keys via environment variables6/15
- Maintenancelast push 4 days ago15/15
- Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
How Safedb compares
Against every graded MCP server, from our own scans and uptime checks. Updated after each scan run.
- Safety score
- 83/100
- higher than 65% of 48,255 servers
- Tools
- 6
- the typical server has 7
- Tools that change things
- 33%
- typical: 0%. Fewer write tools means less an agent can break
- GitHub stars
- 8
- more than 86% of 28,688 servers
- Downloads a week
- 38
- more than 29% of 12,191 servers with a package
What its tools let an agent do: 4 read · 1 change · 1 run or deploy
Install Safedb in Claude Code, Cursor or VS Code
Runs npx -y @safedb/safedb-mcp on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add safedb-mcp -- npx -y @safedb/safedb-mcp
What the publisher says
From the Safedb repository's README, as published. We do not edit it. Read it on GitHub
SafeDB MCP
SafeDB MCP is a secure Model Context Protocol server that lets AI agents inspect and query Postgres, MySQL, MariaDB, and SQLite with strict read-only guardrails. It is designed for teams that want useful database access without handing an agent unrestricted production credentials.
Direct database credentials are dangerous for agents because a single bad prompt, tool call, or generated SQL statement can mutate data, exfiltrate sensitive columns, or run expensive queries. SafeDB MCP puts a policy layer between the agent and your database: only configured schemas and tables are visible, SQL is parsed and validated before execution, row counts are capped, results are masked, and every query attempt is audited.
This project is an MVP. It prefers false positives and blocked queries over unsafe access, and it does not claim perfect SQL security.
Features
- MCP tools: listschemas, listtables, describetable, runreadonlyquery, explainquery, getsafedbpolicy
- Postgres support through pg
- MySQL and MariaDB support through mysql2
- SQLite file support through sql.js
- YAML or JSON config with environment expansion
- AST-backed read-only SQL guardrails for SELECT, WITH ... SELECT, UNION, and EXPLAIN SELECT
- Table detection through joins, CTEs, nested subqueries, aliases, and unions
- Column projection checks that block masked fields selected through aliases or expressions
- Configurable table allowlists, denylists, row limits, and statement timeout
- PII masking: redact, email, partial, and deterministic hash
- JSONL audit log with no raw result data
- CLI binary: safedb-mcp
Quickstart
npx @safedb/safedb-mcp init --output safedb.yaml
DATABASE_URL=postgres://readonly:password@localhost:5432/app npx @safedb/safedb-mcp validate-config --config safedb.yaml
DATABASE_URL=postgres://readonly:password@localhost:5432/app npx @safedb/safedb-mcp test-connection --config safedb.yaml
DATABASE_URL=postgres://readonly:password@localhost:5432/app npx @safedb/safedb-mcp --config safedb.yamlUse a dedicated database role with read-only permissions. SafeDB MCP is a defense-in-depth layer, not a replacement for least-privilege database credentials.
Docker
A Docker image packages SafeDB MCP with Node.js and its production dependencies so it can run the same way on any host with Docker.
Build the image locally:
docker build -t safedb-mcp .Run the MCP server with a mounted config file:
docker run --rm -i \
-e DATABASE_URL=postgres://readonly:password@host.docker.internal:5432/app \
-v "$PWD/safedb.yaml:/config/safedb.yaml:ro" \
safedb-mcpPass CLI commands after the image name:
docker run --rm \
-e DATABASE_URL=postgres://readonly:password@host.docker.internal:5432/app \
-v "$PWD/safedb.yaml:/config/safedb.yaml:ro" \
safedb-mcp --config /config/safedb.yaml validate-configExample Config
database:
type: postgres
url: ${DATABASE_URL}
safety:
default_limit: 100
max_limit: 1000
statement_timeout_ms: 5000
allow_explain: true
access:
schemas:
public:
allow_tables:
- users
- orders
- products
deny_tables:
- secrets
column_masks:
users.email: email
users.phone: partial
users.password_hash: redact
users.ssn: redact
audit:
path: safedb-audit.jsonlFor MySQL or MariaDB, set database.type and use the database name as the access schema:
Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
Safedb: common questions
- Is Safedb MCP server safe?
- Mostly: it is graded B (83/100). Read the Safedb safety report
- How do I install Safedb?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does Safedb need an API key?
- Yes. The registry entry asks for
YOUR_API_KEY. - Is Safedb maintained?
- The last commit was 42 days ago (2026-09-23). The latest release is v0.5.0.
- How does Safedb compare with other MCP servers?
- safety score 83/100 (higher than 65% of 48,255 servers); tools 6 (the typical server has 7); tools that change things 33% (typical: 0%. Fewer write tools means less an agent can break). Full comparison.