Skip to main content
MCP server CX Codex

safedb-mcp — Claude Code MCP server: safe DB queries

This MCP server lets AI agents inspect and query databases under read-only controls. Use it when agents need database context without unrestricted credentials.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add safedb-mcp -e YOUR_API_KEY=<YOUR_API_KEY> -- npx -y @safedb/safedb-mcp
Open on GitHub

What safedb-mcp does

safedb-mcp connects Claude Code and the other supported clients to Postgres, MySQL, MariaDB, or SQLite. Its MCP tools expose schema and table inspection, table descriptions, read-only queries, query plans, and the active safety policy.

Before execution, SQL is parsed and checked against the configured access rules. The server handles joins, CTEs, nested queries, aliases, and unions when checking table access, while limits, timeouts, and PII masking are set in YAML or JSON. Attempts are written to a JSONL audit log without raw result rows.

Use a dedicated database role with read-only permissions for production access. SafeDB MCP adds a policy layer, but it does not replace least-privilege credentials. Write statements, migrations, stored procedures, and COPY are outside its scope.

What it helps with

  • inspect database schemas through an AI agent
  • run approved SQL without write access
  • mask PII columns before returning rows
  • record query attempts without storing raw results

Example prompts for the agent

  • List the available schemas and tables in the connected database.
  • Describe the users table and run a read-only query for recent orders.
  • Explain the query plan and identify every table it touches.

How to install safedb-mcp

Platform CLI

claude mcp add safedb-mcp -e YOUR_API_KEY=<YOUR_API_KEY> -- npx -y @safedb/safedb-mcp

Replace <…> with your own values

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about safedb-mcp

How do I install safedb-mcp in Claude Code?

Run claude mcp add safedb-mcp -e YOUR_API_KEY=<YOUR_API_KEY> -- npx -y @safedb/safedb-mcp.

What does safedb-mcp do?

It gives an AI agent controlled access to schema inspection and read-only SQL for Postgres, MySQL, MariaDB, and SQLite. Policies can limit tables, mask fields, cap rows, and audit requests.

Which database operations are blocked?

Write operations, migrations, stored procedure execution, and COPY are blocked. SQL is checked before execution, and returned rows are capped by the configured limit.

Similar MCP servers

All MCP servers for Data and databases →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor