firebase mcp
The Firebase MCP server provides a standardized interface to interact with Firebase services, including Firebase Authentication, Firestore, and Firebase Storage.
The Firebase MCP server provides a standardized interface to interact with Firebase services, including Firebase Authentication, Firestore, and Firebase Storage.
The Model Context Protocol (MCP) is an open protocol that enables LLM client applications to use tools and access external data sources. This MCP server allows any LLM client that supports the MCP protocol to interact with Firebase services including:
The server exposes Firebase services through MCP tools, making them accessible to LLM clients including Claude Desktop, Cursor, Roo Code, and Cline, while handling authentication and connection management.
Firebase MCP now supports querying sub-collections (collection groups) in Firestore! This allows you to query across all sub-collections with the same name, regardless of their parent document - making it easy to search across your entire database hierarchy with a single query. Perfect for cross-document searches, activity feeds, and unified dashboards.
The easiest way to install the Firebase MCP server is to simply feed your LLM client (like Cline) the llms-install.md file.
The server requires the following environment variables:
SERVICE_ACCOUNT_KEY_PATH
: Path to your Firebase service account key JSON file (required)FIREBASE_STORAGE_BUCKET
: Bucket name for Firebase Storage (optional)[projectId].appspot.com
Add the server configuration to your MCP settings file:
~/Library/Application Support/Claude/claude_desktop_config.json
[project root]/.cursor/mcp.json
~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
)~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
MCP Servers can be installed manually or at runtime via npx (recommended). How you install determines your configuration:
{
"firebase-mcp": {
"command": "npx",
"args": [
"-y",
"@gannonh/firebase-mcp"
],
"env": {
"SERVICE_ACCOUNT_KEY_PATH": "/absolute/path/to/serviceAccountKey.json",
"FIREBASE_STORAGE_BUCKET": "your-project-id.firebasestorage.app"
}
}
}
{
"firebase-mcp": {
"command": "node",
"args": [
"/absolute/path/to/firebase-mcp/dist/index.js"
],
"env": {
"SERVICE_ACCOUNT_KEY_PATH": "/absolute/path/to/serviceAccountKey.json",
"FIREBASE_STORAGE_BUCKET": "your-project-id.firebasestorage.app"
}
}
}
git clone https://github.com/gannonh/firebase-mcp
cd firebase-mcp
npm install
npm run build
To make sure everything is working, simply prompt your client: Please run through and test all of your Firebase MCP tools.
auth_get_user
: Get user details by ID or email{
identifier: string // User ID or email address
}
firestore_add_document
: Add a document to a collection{
collection: string,
data: object
}
firestore_list_collections
: List available collections{
documentPath?: string, // Optional parent document path
limit?: number, // Default: 20
pageToken?: string // For pagination
}
firestore_list_documents
: List documents with optional filtering{
collection: string,
filters?: Array<{
field: string,
operator: string,
value: any
}>,
limit?: number,
pageToken?: string
}
firestore_get_document
: Get a specific document{
collection: string,
id: string
}
firestore_update_document
: Update an existing document{
collection: string,
id: string,
data: object
}
firestore_delete_document
: Delete a document{
collection: string,
id: string
}
firestore_query_collection_group
: Query documents across all sub-collections ?{
collectionId: string, // The collection ID to query across all documents
filters?: Array<{ // Optional filters
field: string,
operator: string, // ==, !=, <, <=, >, >=, array-contains, array-contains-any, in, not-in
value: any
}>,
orderBy?: Array<{ // Optional fields to order by
field: string,
direction?: 'asc' | 'desc' // Default: 'asc'
}>,
limit?: number, // Maximum documents to return (default: 20, max: 100)
pageToken?: string // Token for pagination
}
storage_list_files
: List files in a directory{
directoryPath?: string, // Optional path, defaults to root
pageSize?: number, // Number of items per page, defaults to 10
pageToken?: string // Token for pagination
}
storage_get_file_info
: Get file metadata and download URL{
filePath: string // Path to the file in storage
}
npm run build
The project uses Vitest for testing. Tests can be run against Firebase emulators to avoid affecting production data.
npm install -g firebase-tools
firebase init emulators
firebase emulators:start
npm run test:emulator
The server is structured into three main components:
src/
├── index.ts # Server entry point
└── lib/
└── firebase/
├── authClient.ts # Authentication operations
├── firebaseConfig.ts # Firebase configuration
├── firestoreClient.ts # Firestore operations
└── storageClient.ts # Storage operations
Each client module implements specific Firebase service operations and exposes them as MCP tools.
MIT License - see LICENSE file for details
If you encounter this error when trying to access Firebase Storage:
Complete the initial setup if you haven't already
Verify the correct bucket name
[projectId].appspot.com
[projectId].firebasestorage.app
insteadYou can find your bucket name in the Firebase Console under Storage
Set the FIREBASE_STORAGE_BUCKET
environment variable
"FIREBASE_STORAGE_BUCKET": "your-project-id.firebasestorage.app"
If you see this error:
SERVICE_ACCOUNT_KEY_PATH
is correct and absoluteCheck that the file exists and is readable
Check service account permissions
If you see this error when using firestore_query_collection_group
with filters or ordering:
If you see errors about invalid JSON:
console.log
statements in the codeconsole.error
to avoid interfering with the JSON communicationThe MCP protocol uses stdout for JSON communication
Check for syntax errors in your requests
[
{
"description": "Add a document to a Firestore collection",
"inputSchema": {
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"data": {
"description": "Document data",
"type": "object"
}
},
"required": [
"collection",
"data"
],
"type": "object"
},
"name": "firestore_add_document"
},
{
"description": "List collections in Firestore. If documentPath is provided, returns subcollections under that document; otherwise returns root collections.",
"inputSchema": {
"properties": {
"documentPath": {
"description": "Optional parent document path",
"type": "string"
},
"limit": {
"default": 20,
"description": "Number of collections to return",
"type": "number"
},
"pageToken": {
"description": "Token for pagination to get the next page of results",
"type": "string"
}
},
"required": [],
"type": "object"
},
"name": "firestore_list_collections"
},
{
"description": "List documents from a Firestore collection with optional filtering",
"inputSchema": {
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"filters": {
"description": "Array of filter conditions",
"items": {
"properties": {
"field": {
"description": "Field name to filter",
"type": "string"
},
"operator": {
"description": "Comparison operator",
"type": "string"
},
"value": {
"description": "Value to compare against (use ISO format for dates)",
"type": "any"
}
},
"required": [
"field",
"operator",
"value"
],
"type": "object"
},
"type": "array"
},
"limit": {
"default": 20,
"description": "Number of documents to return",
"type": "number"
},
"pageToken": {
"description": "Token for pagination to get the next page of results",
"type": "string"
}
},
"required": [
"collection"
],
"type": "object"
},
"name": "firestore_list_documents"
},
{
"description": "Get a document from a Firestore collection",
"inputSchema": {
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"id": {
"description": "Document ID",
"type": "string"
}
},
"required": [
"collection",
"id"
],
"type": "object"
},
"name": "firestore_get_document"
},
{
"description": "Update a document in a Firestore collection",
"inputSchema": {
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"data": {
"description": "Updated document data",
"type": "object"
},
"id": {
"description": "Document ID",
"type": "string"
}
},
"required": [
"collection",
"id",
"data"
],
"type": "object"
},
"name": "firestore_update_document"
},
{
"description": "Delete a document from a Firestore collection",
"inputSchema": {
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"id": {
"description": "Document ID",
"type": "string"
}
},
"required": [
"collection",
"id"
],
"type": "object"
},
"name": "firestore_delete_document"
},
{
"description": "Get a user by ID or email from Firebase Authentication",
"inputSchema": {
"properties": {
"identifier": {
"description": "User ID or email address",
"type": "string"
}
},
"required": [
"identifier"
],
"type": "object"
},
"name": "auth_get_user"
},
{
"description": "List files in a given path in Firebase Storage",
"inputSchema": {
"properties": {
"directoryPath": {
"description": "The optional path to list files from. If not provided, the root is used.",
"type": "string"
}
},
"required": [],
"type": "object"
},
"name": "storage_list_files"
},
{
"description": "Get file information including metadata and download URL",
"inputSchema": {
"properties": {
"filePath": {
"description": "The path of the file to get information for",
"type": "string"
}
},
"required": [
"filePath"
],
"type": "object"
},
"name": "storage_get_file_info"
}
]