firebase-mcp
by gannonh
๐ฅ Model Context Protocol (MCP) server for Firebase.
What is firebase-mcp
Firebase MCP
Overview
Firebase MCP enables AI assistants to work directly with Firebase services, including:
- Firestore: Document database operations
- Storage: File management with robust upload capabilities
- Authentication: User management and verification
The server works with MCP client applicatios such as Claude Desktop, Augment Code, VS Code, and Cursor.
โก Quick Start
Prerequisites
- Firebase project with service account credentials
- Node.js environment
1. Install MCP Server
Add the server configuration to your MCP settings file:
- Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json
- Augment:
~/Library/Application Support/Code/User/settings.json
- Cursor:
[project root]/.cursor/mcp.json
MCP Servers can be installed manually or at runtime via npx (recommended). How you install determines your configuration:
Configure for npx (recommended)
{
"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"
}
}
}
Configure for local installation
{
"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"
}
}
}
2. Test the Installation
Ask your AI client: "Please test all Firebase MCP tools."
๐ฅ Latest Features: Storage Upload (v1.3.3)
Firebase MCP now offers powerful file upload capabilities with two specialized tools:
storage_upload
: Upload files from text, base64 content, or local file pathsstorage_upload_from_url
: Import files directly from external URLs
Key Benefits
- Permanent Public URLs: All uploads generate non-expiring public URLs
- Content Type Detection: Automatic detection from file extensions and data
- Multiple Upload Methods: Flexible options for different use cases
- Rich Response Formatting: Clear, well-structured upload confirmations
Upload Methods
-
Local File Path (Recommended for all file types)
{ filePath: "my-report.pdf", content: "/path/to/local/file.pdf" }
-
Base64 Data URL (For smaller files)
{ filePath: "my-image.png", content: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." }
-
Plain Text (For text files)
{ filePath: "readme.md", content: "# My README\n\nThis is a markdown file." }
-
External URL (Using storage_upload_from_url)
{ filePath: "document.pdf", url: "https://example.com/document.pdf" }
โ ๏ธ Important: For binary files like images and PDFs, always use the direct file path method for best reliability.
๐ ๏ธ Setup & Configuration
1. Firebase Configuration
- Go to Firebase Console โ Project Settings โ Service Accounts
- Click "Generate new private key"
- Save the JSON file securely
2. Environment Variables
SERVICE_ACCOUNT_KEY_PATH
: Path to your Firebase service account key JSON (required)FIREBASE_STORAGE_BUCKET
: Bucket name for Firebase Storage (optional, defaults to[projectId].appspot.com
)
3. Client Integration
Claude Desktop
Edit: ~/Library/Application Support/Claude/claude_desktop_config.json
VS Code / Augment
Edit: ~/Library/Application Support/Code/User/settings.json
Cursor
Edit: [project root]/.cursor/mcp.json
๐ API Reference
Firestore Tools
Tool | Description | Required Parameters |
---|---|---|
firestore_add_document |
Add a document to a collection | collection , data |
firestore_list_documents |
List documents with filtering | collection |
firestore_get_document |
Get a specific document | collection , id |
firestore_update_document |
Update an existing document | collection , id , data |
firestore_delete_document |
Delete a document | collection , id |
firestore_list_collections |
List root collections | None |
firestore_query_collection_group |
Query across subcollections | collectionId |
Storage Tools
Tool | Description | Required Parameters |
---|---|---|
storage_list_files |
List files in a directory | None (optional: directoryPath ) |
storage_get_file_info |
Get file metadata and URL | filePath |
storage_upload |
Upload file from content | filePath , content |
storage_upload_from_url |
Upload file from URL | filePath , url |
Authentication Tools
Tool | Description | Required Parameters |
---|---|---|
auth_get_user |
Get user by ID or email | identifier |
๐ป Developer Guide
Installation & Building
git clone https://github.com/gannonh/firebase-mcp
cd firebase-mcp
npm install
npm run build
Running Tests
First, install and start Firebase emulators:
npm install -g firebase-tools
firebase init emulators
firebase emulators:start
Then run tests:
# Run tests with emulator
npm run test:emulator
# Run tests with coverage
npm run test:coverage:emulator
Project Structure
src/
โโโ index.ts # Server entry point
โโโ utils/ # Utility functions
โโโ lib/
โโโ firebase/ # Firebase service clients
โโโ authClient.ts # Authentication operations
โโโ firebaseConfig.ts # Firebase configuration
โโโ firestoreClient.ts # Firestore operations
โโโ storageClient.ts # Storage operations
๐ Troubleshooting
Common Issues
Storage Bucket Not Found
If you see "The specified bucket does not exist" error:
- Verify your bucket name in Firebase Console โ Storage
- Set the correct bucket name in
FIREBASE_STORAGE_BUCKET
environment variable
Firebase Initialization Failed
If you see "Firebase is not initialized" error:
- Check that your service account key path is correct and absolute
- Ensure the service account has proper permissions for Firebase services
Composite Index Required
If you receive "This query requires a composite index" error:
- Look for the provided URL in the error message
- Follow the link to create the required index in Firebase Console
- Retry your query after the index is created (may take a few minutes)
๐ Response Formatting
Storage Upload Response Example
{
"name": "reports/quarterly.pdf",
"size": "1024000",
"contentType": "application/pdf",
"updated": "2025-04-11T15:37:10.290Z",
"downloadUrl": "https://storage.googleapis.com/bucket/reports/quarterly.pdf?alt=media",
"bucket": "your-project.appspot.com"
}
Displayed to the user as:
## File Successfully Uploaded! ๐
Your file has been uploaded to Firebase Storage:
**File Details:**
- **Name:** reports/quarterly.pdf
- **Size:** 1024000 bytes
- **Type:** application/pdf
- **Last Updated:** April 11, 2025 at 15:37:10 UTC
**[Click here to download your file](https://storage.googleapis.com/bucket/reports/quarterly.pdf?alt=media)**
๐ค Contributing
- Fork the repository
- Create a feature branch
- Implement changes with tests (80%+ coverage required)
- Submit a pull request
๐ License
MIT License - see LICENSE file for details
๐ Related Resources
Leave a Comment
Comments section will be available soon. Stay tuned!
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
Ableton Live MCP Server
MCP Server implementation for Ableton Live OSC control
Airbnb MCP Server
AI Agent Marketplace Index Search MCP Server
MCP Server for AI Agent Marketplace Index from DeepNLP
Algorand MCP Implementation
Algorand Model Context Protocol (Server & Client)
mcp-server-apache-airflow
pypi.org/project/mcp-server-apache-airflow/
airtable-mcp-server
๐๏ธ๐ค Airtable Model Context Protocol Server, for allowing AI systems to interact with your Airtable bases
Airtable MCP Server
Search, create and update Airtable bases, tables, fields, and records using Claude Desktop and MCP (Model Context Protocol) clients
Alphavantage MCP Server
A MCP server for the stock market data API, Alphavantage API.
Amadeus MCP Server
Amadeus MCP(Model Context Protocol) Server
Anki MCP Server
An MCP server for Anki
Submit Your MCP Server
Share your MCP server with the community
Submit Now