firestore-guard-mcp
Audits Firebase Firestore security rules and composite index definitions offline, detecting privilege escalations, validation bypasses, PII exposure, and redundant indexes.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@firestore-guard-mcp audit ./firestore.rules and explain any high-severity findings"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
firestore-guard-mcp
Zero-bloat static security analyzer and Model Context Protocol (MCP) server for firestore.rules and firestore.indexes.json.
Catch privilege escalations, create/update validation bypasses, PII exposure, and redundant composite indexes in milliseconds — offline, with zero Firebase Emulator setup, in your terminal, CI pipeline, or AI coding assistant.
Why firestore-guard-mcp?
A single overlooked line in firestore.rules can expose an entire database or let any signed-in user promote themselves to admin. A redundant composite index in firestore.indexes.json silently inflates write latency and storage bills.
firestore-guard-mcp gives you:
Instant offline static analysis — no Java runtime, no Firebase Emulator, no network calls.
Helper function expansion — resolves custom
function isSignedIn()/isOwner()helpers insidefirestore.rulesinstead of doing naive regex matching.Native MCP Server (stdio) — plug directly into Claude Desktop, Claude Code, Cursor, or any MCP host so your AI assistant can audit and harden rules automatically.
CI-ready CLI — deterministic
0–100security score (A–F),--jsonoutput, and--fail-on <severity>exit codes.Zero bloat — only 2 runtime dependencies (
@modelcontextprotocol/sdkandzod).
Related MCP server: shipsafe-mcp
What It Looks Like
firestore-guard-mcp Audit — Project (/app/my-firebase-project)
Score: 34/100 (Grade F) | Total: 5 (critical: 1, high: 2, medium: 2, low: 0, info: 0)
[CRITICAL] FS-RULE-001: Unrestricted public access (line 22, match /databases/{database}/documents/posts/{postId})
Issue: Rule allows read unconditionally (if true) on /databases/{database}/documents/posts/{postId}.
Code: allow read: if true;
Fix: Restrict access with explicit authentication, ownership, or role checks instead of allowing unconditional access.
[HIGH] FS-RULE-006: Create vs. update validation bypass (line 16, match /databases/{database}/documents/users/{userId})
Issue: On /databases/{database}/documents/users/{userId}, `create` validates incoming document fields, but `update` omits validation/diff checks.
Code: allow update: if request.auth.uid == userId;
Fix: Enforce the same schema/type/size checks on `update` and lock immutable fields using `request.resource.data.diff(resource.data).affectedKeys()`.
[HIGH] FS-RULE-005: Email authorization without email_verified check (line 29, match /databases/{database}/documents/admin/{docId})
Issue: Rule checks `request.auth.token.email` without verifying `request.auth.token.email_verified == true`.
Code: allow read, write: if request.auth.token.email == 'admin@example.com';
Fix: Require `request.auth.token.email_verified == true` alongside any `request.auth.token.email` comparison.
[MEDIUM] FS-IDX-004: Redundant prefix composite index (match orders)
Issue: indexes[0] (orders) is a strict prefix of indexes[1] with identical sort/array modes.
Fix: Remove indexes[0] because queries it serves are already covered by indexes[1].Quick Start Guide
1. Clone & Build (from source)
git clone https://github.com/Adjureee/firestore-guard-mcp.git
cd firestore-guard-mcp
npm install
npm run build2. Run Your First Audit (CLI)
Audit an entire Firebase project (auto-discovers firebase.json or default firestore.rules & firestore.indexes.json):
node ./dist/cli/index.js audit /path/to/your-firebase-projectAudit a single file:
# Audit security rules
node ./dist/cli/index.js rules ./firestore.rules
# Audit composite indexes & field overrides
node ./dist/cli/index.js indexes ./firestore.indexes.jsonUse in CI pipelines (returns exit code 1 if any finding meets or exceeds --fail-on):
# Fail the build on any high or critical issue, output JSON for tooling
node ./dist/cli/index.js audit . --fail-on high --jsonCLI Reference
Command / Flag | Description |
| Auto-discover and audit |
| Audit a specific |
| Audit a specific |
| Start the MCP server on stdio (also the default when run with no arguments) |
| Emit structured JSON report instead of formatted text |
| Exit with code |
| Override rules file path when running |
| Override indexes file path when running |
| Print package version |
| Show CLI usage |
3. Connect as an MCP Server
firestore-guard-mcp speaks standard MCP over stdio and exposes three tools:
MCP Tool | Arguments | Purpose |
|
| Audit raw rules text or a local |
|
| Audit raw JSON or a local |
|
| Auto-discover via |
Claude Code
claude mcp add firestore-guard -- node /absolute/path/to/firestore-guard-mcp/dist/cli/index.js serveClaude Desktop / Cursor / Windsurf / Antigravity
Add to your MCP configuration file (e.g., claude_desktop_config.json or .cursor/mcp.json):
{
"mcpServers": {
"firestore-guard": {
"command": "node",
"args": ["/absolute/path/to/firestore-guard-mcp/dist/cli/index.js", "serve"]
}
}
}Once connected, ask your AI assistant:
"Run
audit_firestore_projecton this repo, explain every critical/high finding, and patchfirestore.rulesuntil the score is 100/100."
4. Programmatic TypeScript / Node.js API
import {
auditFirestoreRules,
auditFirestoreIndexes,
auditFirestoreProject,
formatReport,
} from 'firestore-guard-mcp';
const rulesReport = auditFirestoreRules(rulesSource, 'firestore.rules');
console.log(formatReport(rulesReport));
const indexesReport = auditFirestoreIndexes(indexesJson, 'firestore.indexes.json');
const projectReport = auditFirestoreProject({ projectDir: './my-firebase-app' });Audit Rules Reference
Firestore Security Rules (firestore.rules)
Rule ID | Severity | What It Catches |
| Critical | Unrestricted public access ( |
| Critical | Overly permissive recursive wildcard ( |
| High | Missing or legacy |
| High | Broad authenticated write ( |
| High |
|
| High |
|
| High | Privilege escalation via user-supplied |
| Medium |
|
| Medium | Broad read/list access on sensitive collections ( |
| Medium | Missing data type ( |
| Medium | Temporary or expired test-mode time-bomb rules ( |
| Low | High |
| Low | Coarse-grained |
| Info | Empty rules file or missing |
Firestore Indexes (firestore.indexes.json)
Rule ID | Severity | What It Catches |
| Critical | Invalid JSON syntax or malformed top-level structure |
| High | Malformed composite index (missing |
| High | Exact duplicate composite index definitions |
| Medium | Redundant prefix composite index already covered by a wider index |
| Medium | Unnecessary single-field composite index (Firestore auto-indexes single fields) |
| High | Multiple |
| Low | Wide composite index (>4 fields) causing write amplification |
| Low | Broad |
| High | Malformed or duplicate |
Scoring
Every audit starts at 100 and deducts per finding:
Critical:
-30High:
-15Medium:
-8Low:
-3Info:
0
Grades: A (90–100), B (80–89), C (70–79), D (50–69), F (0–49).
Development
npm run typecheck # TypeScript strict typecheck (tsc --noEmit)
npm test # Vitest unit, CLI, and MCP InMemoryTransport tests
npm run build # Bundle ESM library, .d.ts types, and CLI via tsupLicense
Available Tools
3 toolsaudit_firestore_indexesC
Audit firestore.indexes.json for schema errors, duplicate/redundant indexes, and write amplification.
Inputs: filePath, indexesContent.
audit_firestore_projectB
Auto-discover and audit firestore.rules and firestore.indexes.json in a Firebase project directory.
Inputs: rulesPath, projectDir, indexesPath.
audit_firestore_rulesC
Audit Firestore security rules for vulnerabilities and anti-patterns.
Inputs: filePath, rulesContent.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The two file-level auditors are clearly distinct from each other, but audit_firestore_project overlaps heavily by auto-discovering and auditing both files, so an agent must guess whether to call the project-level tool alone or the two granular tools as well. The descriptions help somewhat but do not clarify the relationship or recommended call order.
All three names follow the same audit_firestore_<target> pattern with a consistent verb and resource scope. The project tool's broader target is still readable within the same convention.
Three tools is thin but defensible for a narrowly scoped audit-only server. However, one tool (audit_firestore_project) largely composites the other two, meaning the surface only really offers two distinct capabilities.
The server covers auditing of rules, indexes, and project discovery, which is coherent lifecycle coverage for a read-only audit role. It is a dead end for remediation though: there is no tool to suggest or apply fixes, regenerate indexes, or validate a corrected rules file after an audit.
Maintenance
Related MCP Connectors
Detects database migration table locks, terraform cost leaks, and OWASP API flaws.
Checks AI-written code for leaked keys and made-up packages, on your machine. Never uploads code.
AI code governance and code review for Claude Code, Copilot and Cursor. Checks rules and security.
Supabase RLS simulator, app key-leak check, email sender check, DMARC and payment-fraud checks.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables auditors to scan cloud IAM policies for privilege-escalation paths, wildcards, and risky grants directly within Cursor or Claude Code, using a deterministic rule engine that runs entirely on local infrastructure.1-

shipsafe-mcpofficial
AlicenseAqualityCmaintenanceEnables AI coding assistants to scan projects for security issues such as leaked API keys, missing Supabase RLS, open Firebase rules, unauthenticated routes, and hallucinated packages, then fix and verify the results.81MIT- AlicenseAqualityCmaintenanceEnables AI coding assistants to check whether an API key is safe to expose, audit Supabase Row Level Security, generate owner-based RLS policy templates, and run a builder-specific pre-launch security checklist. Runs locally over stdio with no network calls, telemetry, or file access.5MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding assistants to run static analysis on GitHub repositories, raw code snippets, or local directories to detect cloud cost leaks in Terraform/AWS configs, PostgreSQL migration table-lock hazards, and OWASP/Next.js API security gaps. Each finding returns structured severity, line-level detail, and drop-in fixes.MIT