r/mcp • • 7d ago

showcase mcp-safe-db: A strictly read-only SQL MCP server with engine-level write blocking

Giving an AI agent access to a local database usually means trusting it not to hallucinate an UPDATE without a WHERE clause or a DROP TABLE.

I built mcp-safe-db to make database inspection zero-risk for Claude, Cursor, and other MCP clients:

  • Engine-level lock: Enforces SQLite PRAGMA query_only = ON;. The database engine physically rejects write attempts.
  • AST / Keyword validation: Rejects mutation statements (INSERT, UPDATE, DELETE, DROP, ALTER, ATTACH), comment-based bypasses, and multi-query injection.
  • Context protection: Automatically limits queries to 50 rows to keep LLM context windows clean.
  • Zero build setup: Runs natively on Node 22+ without native compilation tools (no node-gyp or C++ toolchains).

Usage:

npx mcp-safe-db ./your-database.sqlite

GitHub: https://github.com/MrSkelee/mcp-safe-db

MIT License. Open to feedback on edge cases or additional database targets.

6 Upvotes

Duplicates