Listed from the MCP registry; nobody on Odel publishes it.
Safety-first Database Guardrail & Sandboxing MCP Server for AI Coding Agents
Runs on your machine from its package; the steps are below.

At most: moves money, runs code or commands, deletes data, or sends messages for you.
Odel charges nothing per call. The publisher may charge for its own service.
Runs locally over stdio
This server isn't hosted — your MCP client launches it from a package registry. Use one of the commands below, or drop the config into your client (e.g. Claude Desktop).
Run
npx -y @ritualdev-lab/dbshield
MCP client config
{
"mcpServers": {
"dbshield-database-guardrail-sandboxing-mcp-server": {
"command": "npx",
"args": [
"-y",
"@ritualdev-lab/dbshield"
]
}
}
}Stop AI coding agents from running DROP TABLE, bulk DELETE, or unindexed scans against your database — including Prisma, Drizzle, and TypeORM prepared statements.
Local wire-protocol SQL firewall, dry-run blast-radius sandbox, and non-blocking ChatOps approval proxy for PostgreSQL, MySQL, and SQLite. Works transparently with Claude Code, Cursor, Windsurf, and any SQL client or ORM.
# Start the local wire-protocol firewall proxy (points at your local Postgres on :5432)
npx @ritualdev-lab/dbshield proxy --port 5433 --tier STRICT
# Or expose DBShield as an MCP server for Claude Desktop / Cursor
npx @ritualdev-lab/dbshield mcp
[DBShield :5433] Intercepted Extended Query (Parse/Bind/Execute):
SQL: DELETE FROM accounts WHERE created_at < '2026-01-01';
DryRun: 14,820 rows affected (ROLLBACK executed in 3.1ms — 0 DB locks held)
Action: BLOCKED -> Sent replay-proof HMAC approval card to Slack (#db-approvals)
Recorded with Charm VHS from
assets/demo.tape.
pg send PostgreSQL Extended Query frames (Parse 'P' / Bind 'B' / Execute 'E') instead of Simple Query 'Q'. DBShield reconstructs bound parameterized SQL ASTs on the wire before evaluation.BEGIN ... locks kills production: Waiting for a Slack click inside an open transaction locks tables. DBShield computes a pre-image state checksum (<5ms), immediately executes ROLLBACK to free the pool, and re-verifies zero state drift on a fresh connection when approved.HMAC-SHA256(secret, normalized_sql_ast | db_id | expires_at | single_use_nonce) with 10-minute TTL and 403 Token Already Consumed on replay.Full Guide · Threat Model · Docs · GitHub Issues & Good First Issues
When an AI coding agent acts on your database, static AST rules and regex patterns only catch known bad syntax (like DROP TABLE or WHERE 1=1). They cannot catch semantically plausible queries where the effect completely diverges from the user's intent:
┌──────────────────────────────────────┐ ┌────────────────────────────────────────────────────────────┐
│ AGENT'S STATED INTENT │ │ AGENT'S EMITTED SQL │
│ "Update avatar for user #402" │ ──► │ UPDATE users SET role = 'admin' WHERE id = 402; │
│ Expected Effect: 1 row, non-sens col │ │ Simulated Effect: Privilege escalation to superadmin! │
└──────────────────────────────────────┘ └────────────────────────────────────────────────────────────┘
▲
│
🚨 INTENT VS. EFFECT GAP DETECTED (BLOCKED)
┌──────────────────────────────────────┐ ┌────────────────────────────────────────────────────────────┐
│ AGENT'S STATED INTENT │ │ AGENT'S EMITTED SQL │
│ "Archive test trial accounts" │ ──► │ DELETE FROM accounts WHERE created_at < '2026-01-01'; │
│ Expected Blast Radius: ~5 rows │ │ Simulated Effect: 14,820 customer production accounts lost │
└──────────────────────────────────────┘ └────────────────────────────────────────────────────────────┘
▲
│
🚨 BLAST RADIUS GAP DETECTED (BLOCKED & ROLLED BACK)
sequenceDiagram
autonumber
actor Developer as LLM Agent / Developer
participant Proxy as DBShield Wire Proxy (:5432)
participant Guard as AST Normalizer & Intent Guard
participant Sandbox as Shadow Dry-Run Sandbox
participant OS as SQLite VFS OS Shim
participant Approvals as ChatOps (Slack / Teams)
participant DB as Production Database
Developer->>Proxy: SQL Mutation + Stated Intent Context
Proxy->>Guard: Lexical Normalization & Semantic Intent Check
alt In-line Comment Evasion / Unicode Smuggling
Guard-->>Developer: ❌ [BLOCKED] Query normalization violation
end
Guard->>Sandbox: Execute in Isolated Transaction Envelope (BEGIN ... ROLLBACK)
Sandbox->>OS: Page-Level Write Interception (Token Verified)
OS-->>Sandbox: Intercepted OS Page Diffs & Computed Row Mutations
Sandbox-->>Guard: Exact Blast Radius (Affected Rows, Column Mutations, DDL)
Guard->>Guard: Gap Analysis: Compare Intent vs. Effect
alt Gap Detected (Row Count Regressed OR Column Privilege Mismatch)
Guard->>Approvals: Dispatch Two-Man Approval Card (Slack / Teams)
Approvals-->>Developer: ⏸️ Mutation Paused Pending Human Sign-Off
else Intent Aligned & Safe Blast Radius
Guard->>DB: Monotonic Fencing Token Commit
DB-->>Developer: ✅ Committed Successfully with HMAC-SHA256 Audit Trail
end
flowchart TD
A["Agent Intent: 'Update Profile'"] --> B["Emitted SQL: 'UPDATE users SET role=admin'"]
B --> C["DBShield Wire Proxy (:5432 / :3306)"]
C --> D{"AST Lexical Normalizer<br/>(Strip Evasion & Comment Injection)"}
D -->|Passed| E["Shadow Sandbox Simulation<br/>(BEGIN ... ROLLBACK)"]
D -->|Violation| Block1["❌ Terminate with Security Alert"]
E --> F["OS Page-Level VFS Shim Interception"]
F --> G["Calculate Exact Mutation Blast Radius<br/>(Rows Mutated, Columns Modified)"]
G --> H{"Intent vs. Effect Gap Analyzer"}
H -->|"GAP DETECTED!<br/>(Privilege escalation or row explosion)"| I["🚨 Route to Slack / Teams Two-Man Rule"]
H -->|"INTENT ALIGNED<br/>(Blast radius matches intent)"| J["Sign with Monotonic Fencing Token"]
J --> K["Commit to Production Database"]
I -->|Human Approves| K
I -->|Human Rejects| L["Atomic Rollback & HMAC Ledger Alert"]
When autonomous AI coding agents interact directly with databases:
WHERE clause turns a targeted fix into an unrecoverable DELETE FROM users; or UPDATE orders SET status = 'cancelled';.DROP TABLE, TRUNCATE) instead of running non-destructive migrations.LIMIT clauses exhaust connection pools and lock production tables.DBShield sits between your AI Agent and your Database as an intelligent, zero-overhead safety firewall.
DBShield is an open-source database guardrail, virtual schema masking proxy, and MCP server designed to protect relational databases (PostgreSQL, SQLite, MySQL) from accidental bulk mutations, schema corruption, and PII leaks when queried by autonomous AI coding agents.
DBShield operates with a Two-Phase Distributed Dry-Run Engine:
UPDATE, DELETE, DROP), DBShield intercepts the query and executes it in an isolated transaction rollback block (BEGIN ... ROLLBACK).When AI coding agents run introspection queries like SELECT * FROM information_schema.tables, DBShield intercepts the wire protocol and rewrites catalog responses. Sensitive internal tables (credentials, sessions, api_keys) and restricted columns are hidden entirely from the agent's view.
BEGIN TRANSACTION READ ONLY; ... ROLLBACK;). Calculates the exact difference between the agent's stated intent and actual row/column impact before anything touches production.SqliteVfsShim): Intercepts OS disk page read/write operations (4096-byte pages), blocking agents from altering .sqlite or .db files via direct filesystem access outside the DBShield wire proxy (UNAUTHORIZED_DIRECT_FS_WRITE).RaftConsensusCoordinator) synchronizing transaction isolation leases and two-phase commit votes across clustered proxies to eliminate split-brain mutations.HmacAuditLedger): Meets PCI-DSS v4.0 Requirement 10 and SOC 2 CC6.8. Implements strictly contiguous monotonic sequence numbers, query payload hashing, and Merkle tree root calculation for tamper-evident compliance exports.SEL/**/ECT), multi-statement injection, and unconstrained deletes.credentials, internal_audit, admin_*) from information_schema / catalog introspection and masks restricted columns from agent context.CREATE INDEX [CONCURRENTLY] DDL statements with cost regression alerting.:3100) streaming live agent queries, risk scores, and PII redactions, featuring 1-click "Approve / Reject" buttons for sensitive mutations.Run the auto-installer to configure your local Claude Desktop:
npx @ritualdev-lab/dbshield install-claude
Or manually add to claude_desktop_config.json:
{
"mcpServers": {
"dbshield": {
"command": "npx",
"args": ["-y", "@ritualdev-lab/dbshield", "start"]
}
}
}
Run inside your workspace to create or update .cursor/mcp.json:
npx @ritualdev-lab/dbshield install-cursor
Run DBShield as a transparent TCP wire proxy on :5433 (or :5432). Any ORM (Prisma, Drizzle, SQLAlchemy), AI agent, or CLI connects directly:
npx @ritualdev-lab/dbshield proxy --port 5433 --upstream-host 127.0.0.1 --upstream-port 5432
In your application or .env:
DATABASE_URL="postgres://user:password@127.0.0.1:5433/production_db"
# Check status and inspect connected database
npx @ritualdev-lab/dbshield status
# Initialize starter configuration file
npx @ritualdev-lab/dbshield init
Start the real-time query approval web interface (:3100):
npx @ritualdev-lab/dbshield dashboard --port 3100
Open http://localhost:3100 to inspect live agent queries, risk scores, PII redactions, and 1-click "Approve / Reject" buttons for sensitive mutations.
dbshield.config.json){
"$schema": "https://raw.githubusercontent.com/RitualDev-Lab/DBShield/main/schema.json",
"dialect": "sqlite",
"storagePath": "./dev.db",
"safetyTier": "BALANCED",
"maxRowsPerMutation": 50,
"allowDestructiveDDL": false,
"enablePiiMasking": true,
"customPiiColumns": ["token", "ssn", "secret_key"]
}
| Tier | Mutation Limit | Destructive DDL | Dry-Run Required | PII Masking | Best For |
|---|---|---|---|---|---|
STRICT | Max 1 row | ❌ Blocked | ✅ Always Required | 🔒 Enforced | Production, Staging |
BALANCED | Max 50 rows | ❌ Blocked | ✅ On Bulk Writes | 🔒 Enforced | Local Dev, Team Collaboration |
PERMISSIVE | Max 500 rows | ⚠️ Warned | Optional | Optional | Sandbox Benchmarks |
| Tool | Description |
|---|---|
db_status | Inspect gateway connectivity, active safety tier, cost gate, and database statistics. |
db_describe_schema | Safe introspection of tables, columns, constraints, and relations. |
db_query | Safe read and mutation query execution with automatic PII redaction, cost gate, and DDL checks. |
db_dry_run | Test mutation inside an auto-rollback transaction with row delta preview and intent verification. |
db_commit | Execute verified mutation accompanied by cryptographic authorization token. |
db_explain_query | Analyze query execution plans, detect unindexed full-table scans, and receive index hints. |
db_audit_log | Retrieve compliance query audit trail, blocked operations, and risk scores. |
db_validate_migration | Validate DDL migration scripts for lock hazards and generate zero-downtime execution recipes. |
db_check_schema_drift | Audit live database foreign keys for missing indexes and detect structural schema drift. |
db_check_semantic_intent | Check stated English user intent against SQL AST target columns to stop unauthorized privilege/financial mutations. |
db_distributed_dry_run | Simulate atomic mutations across multi-store environments (Postgres, SQLite, Redis) and receive unified token. |
db_distributed_commit | Execute two-phase distributed commit across multi-store environments with cryptographic tamper verification. |
DBShield enforces rigorous runtime guarantees across the SQL lifecycle. Guarantees are verified transactionally, ensuring mutations never exceed approved scope even if database state drifts:
| SQL Operation | Classification Mechanism | Static AST Guardrail | Execution Boundary & Rollback | Data Masking & Privacy |
|---|---|---|---|---|
| SELECT | Prepared-statement column reflection (stmt.columns()) | Detects missing LIMIT in STRICT tier; warns if limit exceeds server cap | Streaming iterator (stmt.iterate()) caps memory; truncates at maxRowsPerRead | Zero-leak dynamic PII masking on result rows |
| WITH ... (CTE) | Prepared-statement column reflection & recursive AST analysis | Recursively extracts underlying mutated tables & verifies read safety | Streaming iterator (stmt.iterate()) with hard read ceiling | Zero-leak dynamic PII masking on result rows |
| UPDATE (Targeted) | AST evaluation & tautology checker (evaluateWhereClause) | Blocks unconstrained updates, WHERE 1=1, WHERE true, tautological OR | Atomic transaction; rolls back if affected rows exceed maxMutationRows | Literal masking in logs & database errors |
| DELETE (Targeted) | AST evaluation & tautology checker (evaluateWhereClause) | Blocks unconstrained deletes, WHERE 1=1, tautological OR | Atomic transaction; rolls back if affected rows exceed maxMutationRows | Literal masking in logs & database errors |
| INSERT | AST evaluation & dialect parser | Pre-flight dry run simulation required under STRICT tier | Atomic transaction; rolls back if inserted rows exceed maxMutationRows | Redacts sensitive literals in (cols) VALUES (vals) |
| DROP TABLE / TRUNCATE | AST statement opcode inspection | CRITICAL BLOCK: Intercepted before database touch unless explicitly overridden | Direct execution blocked | Audit log records blocked attempt with high risk score |
| ALTER TABLE DROP COLUMN | AST expression visitor (expr.action) | BLOCKED: Intercepted before database touch to prevent schema data loss | Direct execution blocked | Audit log records blocked attempt |
| EXPLAIN / PRAGMA | Prepared-statement column reflection | Safe read-only inspection | Read capped at maxRowsPerRead | Sanitized output |
params), database identity (storagePath), safety tier, and simulated affected row count.PARAMS_MISMATCH, QUERY_TAMPERED).maxRowsPerMutation is a hard safety limit across all safety tiers (STRICT, BALANCED, PERMISSIVE), immediately refusing dry-run authorization (EXCESSIVE_BLAST_RADIUS).db_commit run inside an atomic transaction block: if actual row modifications exceed the authorized ceiling, DBShield immediately executes ROLLBACK; and aborts.simulatedAffectedRows != actualChanges), DBShield rolls back the transaction with [SIMULATION_DELTA_DRIFT].db_audit_log returns strictly sanitized compliance records.stmt.iterate().maxRowsPerRead without buffering the full dataset into Node.js heap memory, returning agent-friendly pagination metadata (totalReturned, isTruncated, maxAllowedRows, hasMore, warning).stmt.columns() > 0) and recursive AST extraction.WITH active AS (...) SELECT ...) and leading single-line (--) or multi-line (/* */) comments are correctly classified and executed without error.For production and shared environments, DBShield should be paired with database-level least privilege:
chmod 600 /var/data/production.db
chown dbshield:dbshield /var/data/production.db
{
"storagePath": "file:/var/data/production.db?mode=ro",
"safetyTier": "STRICT"
}
-- Create isolated role
CREATE ROLE agent_user WITH LOGIN PASSWORD 'strong_random_password';
-- Grant only targeted DML on application tables (NO DROP, TRUNCATE, or ALTER)
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO agent_user;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
db_dry_run outputs can be piped to an external human-in-the-loop review system (Slack, Teams, or ticketing webhook) before the token is submitted to db_commit.DBShield is packaged as an enterprise container with an unprivileged non-root user (UID 10001), native Prometheus metrics exporter, and a production Kubernetes Helm chart:
PostgreSQL Clients / AI Agents ──► DBShield Wire Proxy (:5433) ──► Upstream PostgreSQL (:5432)
│
└──► Prometheus Scraper (:9090/metrics)
└──► Kubernetes Probes (:9090/healthz, /ready)
Launch PostgreSQL, DBShield Wire Proxy, and Prometheus in one command:
docker compose up -d
127.0.0.1:5433 (Targeting PostgreSQL on :5432)http://localhost:9091http://localhost:9090/metricshttp://localhost:9090/healthzdocker run -d \
--name dbshield-proxy \
-p 5433:5433 \
-p 9090:9090 \
-e DBSHIELD_UPSTREAM_HOST=postgres.internal \
-e DBSHIELD_UPSTREAM_PORT=5432 \
-e DBSHIELD_SAFETY_TIER=BALANCED \
ghcr.io/ritualdev-lab/dbshield:0.2.0
Deploy high-availability DBShield replicas (with HorizontalPodAutoscaler and Prometheus ServiceMonitor):
# Add or install local chart
helm install dbshield ./charts/dbshield \
--set proxy.upstreamHost="my-db.postgres.database.azure.com" \
--set proxy.safetyTier="BALANCED" \
--set replicaCount=2 \
--set autoscaling.enabled=true
/metrics)dbshield_up: Proxy health status (1 = healthy)dbshield_connections_active: Real-time active client connectionsdbshield_queries_total{status, safety_tier, operation}: Total queries evaluateddbshield_queries_blocked_total{rule, severity}: Queries intercepted and preventeddbshield_query_duration_seconds: Histogram measuring query evaluation latencydbshield_cost_savings_dollars_total: Estimated cloud spend saved from blocked runaway queriesDBShield provides deterministic, zero-data-custody database protection backed by enterprise contractual assurances:
uses: RitualDev-Lab/DBShield@v0.2.0).security@ritualdev.insupport@ritualdev.indeveloper@ritualdev.inDBShield is 100% open-source and MIT-licensed. Your sponsorship directly finances our multi-database regression testing infrastructure (PostgreSQL, MySQL, SQLite, MongoDB), automated benchmark CI runners, and high-availability MCP registry telemetry.
⚡ 1-Click Dodo Payments Checkout • 🎁 Interactive Donation Form (USD & INR UPI) • ❤️ GitHub Sponsors
🔒 Zero physical shipping required. Powered by Dodo Payments (Merchant of Record) with instant tax invoice and global payment methods (Cards, UPI, Apple Pay).
MIT © RitualDev Lab