Claude Code Firebase MCP Integration

Written by Michael Lip · Solo founder of Zovo · $400K+ on Upwork · 100% JSS Join 50+ builders · More at zovo.one

Integrating Firebase with Claude Code through MCP gives Claude direct access to Firestore documents, Authentication records, and Cloud Functions logs. Instead of switching between the Firebase Console and your editor, Claude can query your database, check auth states, and debug function errors right from the terminal.

The Problem

Firebase developers constantly switch between the Firebase Console, the CLI, and their code editor. When debugging a Firestore query that returns unexpected results or a Cloud Function that fails silently, you end up copy-pasting data between tools. Claude Code can read your source files, but without MCP it cannot see your live Firebase data or logs.

Quick Solution

  1. Install the Firebase MCP dependencies:
npm install -g firebase-tools
pip install mcp firebase-admin
  1. Initialize your Firebase Admin SDK credentials:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
  1. Create firebase_mcp.py:
from mcp.server.fastmcp import FastMCP
import firebase_admin
from firebase_admin import credentials, firestore

cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred)
db = firestore.client()

mcp = FastMCP("firebase-tools")

@mcp.tool()
def query_collection(collection: str, limit: int = 10) -> str:
    """Query a Firestore collection and return documents."""
    docs = db.collection(collection).limit(limit).stream()
    results = []
    for doc in docs:
        results.append(f"{doc.id}: {doc.to_dict()}")
    return "\n".join(results) if results else "No documents found."

@mcp.tool()
def get_document(collection: str, doc_id: str) -> str:
    """Get a specific Firestore document by ID."""
    doc = db.collection(collection).document(doc_id).get()
    if doc.exists:
        return f"{doc.id}: {doc.to_dict()}"
    return "Document not found."
  1. Add to .mcp.json:
{
  "mcpServers": {
    "firebase-tools": {
      "command": "python",
      "args": ["firebase_mcp.py"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
      }
    }
  }
}
  1. Launch Claude Code and ask it to query your Firestore collections.

How It Works

The Firebase Admin SDK connects to your Firebase project using a service account, giving it server-level access to Firestore, Authentication, and other services. The MCP server wraps these capabilities as tools that Claude Code can invoke.

When Claude needs to debug a query, it calls the query_collection tool to see actual data. This eliminates the guesswork of reading Firestore rules and query code without seeing real documents. The get_document tool lets Claude fetch specific records by ID for targeted debugging.

CLAUDE.md should document your Firestore data model so Claude understands collection names, document structures, and security rules context. This helps Claude write better queries and suggest fixes aligned with your schema.

Common Issues

Service account permissions error. Ensure your service account has the Cloud Datastore User role in Google Cloud IAM. The default Firebase Admin SDK service account has this, but custom accounts may not.

MCP server crashes on startup. The firebase-admin package requires google-cloud-firestore, which has native dependencies. If installation fails, try pip install firebase-admin --no-binary :all: or use a virtual environment with Python 3.10+.

Stale data after writes. Firestore reads through the Admin SDK are strongly consistent for document reads but eventually consistent for queries. If Claude writes a document and immediately queries the collection, the document may not appear. Add a small delay or use get_document directly.

Example CLAUDE.md Section

# Firebase Project

## Stack
- Frontend: Next.js 14 with Firebase JS SDK
- Backend: Cloud Functions (Node.js 20)
- Database: Firestore (Native mode)
- Auth: Firebase Authentication (email + Google)

## Firestore Collections
- users/{uid} — profile data, settings
- posts/{postId} — content, authorUid, createdAt
- comments/{commentId} — postId, authorUid, text

## MCP Tools
- query_collection: Read documents (read-only)
- get_document: Fetch by ID (read-only)

## Rules
- Never write to production Firestore from MCP tools
- Use emulator for write operations: firebase emulators:start
- Security rules are in firestore.rules
- Cloud Functions code is in functions/ directory

Best Practices



I'm a solo developer in Vietnam. 50K Chrome extension users. $500K+ on Upwork. 5 Claude Max subscriptions running agent fleets in parallel. These are my actual CLAUDE.md templates, orchestration configs, and prompts. Not a course. Not theory. The files I copy into every project before I write a line of code. **[See what's inside →](https://zovo.one/lifetime?utm_source=ccg&utm_medium=cta-default&utm_campaign=claude-code-firebase-mcp)** $99 once. Free forever. 47/500 founding spots left.

Related Reading

Built by theluckystrike. More at zovo.one