Firestore MCP Server
Provides secure, permission-controlled access to Firebase Firestore with full CRUD operations, advanced queries, subcollection support, batch operations, transactions, and atomic field value operations for managing documents and collections.
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 MCP Server get all users from the users collection"
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 MCP Server
A Model Context Protocol (MCP) server that provides secure, permission-controlled access to Firebase Firestore. This server allows AI assistants and other MCP clients to interact with Firestore databases through a standardized interface.
Features
Core Functionality
🔐 Granular Permissions: Control access at the collection and operation level
📄 Full CRUD Operations: Create, read, update, and delete documents
🔍 Advanced Queries: Support for filtering, ordering, and limiting results
📁 Subcollection Support: Work with nested collections and documents
🔄 Batch Operations: Execute multiple operations atomically
💾 Transactions: Ensure data consistency with transactional operations
🎯 Field Value Operations: Atomic increments, array operations, and server timestamps
Security & Control
✅ Collection-level access control
🛡️ Operation-specific permissions (read, write, delete, query)
🔒 Default deny with explicit allow rules
📋 Conditional permissions (coming soon)
Related MCP server: MCP Firebase Server
Installation
Using npm/yarn/pnpm
npm install mcp-firestore
# or
yarn add mcp-firestore
# or
pnpm add mcp-firestoreFrom Source
git clone https://github.com/yourusername/mcp-firestore.git
cd mcp-firestore
pnpm install
pnpm buildConfiguration
Environment Variables
Create a .env file with your Firestore configuration:
# Required
FIRESTORE_PROJECT_ID=your-project-id
# Optional - for authentication
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.jsonPermission Configuration
Create a permissions.json file to control access:
{
"collections": [
{
"collectionId": "users",
"operations": ["read", "write", "query"]
},
{
"collectionId": "posts",
"operations": ["read", "query"]
}
],
"defaultAllow": false
}Usage
Starting the Server
# With default permissions
mcp-firestore
# With custom permissions file
mcp-firestore --config permissions.json
# With full access (development only)
mcp-firestore --full-access
# With read-only access to specific collections
mcp-firestore --read-only --collections users,postsClaude Desktop Integration
Add to your Claude Desktop configuration:
{
"servers": {
"firestore": {
"command": "mcp-firestore",
"args": ["--config", "path/to/permissions.json"],
"env": {
"FIRESTORE_PROJECT_ID": "your-project-id"
}
}
}
}Available Tools
Basic Operations
firestore-list-collections
List all accessible collections
{}firestore-get-collection
Get all documents from a collection
{ "collectionId": "users" }firestore-get-document
Get a specific document
{ "collectionId": "users", "documentId": "user123" }firestore-create-document
Create a new document
{ "collectionId": "users", "documentId": "user123", "data": { "name": "John Doe", "email": "john@example.com" } }firestore-update-document
Update an existing document
{ "collectionId": "users", "documentId": "user123", "data": { "name": "Jane Doe" } }firestore-delete-document
Delete a document
{ "collectionId": "users", "documentId": "user123" }
Query Operations
firestore-query-collection
Query documents with filters
{ "collectionId": "users", "filters": [ { "field": "age", "operator": ">", "value": 18 } ], "orderBy": { "field": "createdAt", "direction": "desc" }, "limit": 10 }
Subcollection Operations
firestore-list-subcollections
List subcollections of a document
{ "documentPath": "users/user123" }firestore-get-collection-by-path
Get documents from a subcollection
{ "collectionPath": "users/user123/orders" }firestore-create-document-by-path
Create a document in a subcollection
{ "collectionPath": "users/user123/orders", "data": { "item": "Widget", "quantity": 2 } }
Batch Operations
firestore-batch-write
Execute multiple write operations atomically
{ "operations": [ { "type": "create", "collectionPath": "products", "documentId": "product1", "data": { "name": "Widget" } }, { "type": "update", "documentPath": "inventory/product1", "data": { "count": 100 } } ] }firestore-batch-read
Read multiple documents in one operation
{ "documentPaths": [ "users/user1", "users/user2", "products/product1" ] }firestore-transaction
Execute a transaction with reads and conditional writes
{ "reads": ["products/product1"], "operations": [ { "type": "update", "documentPath": "products/product1", "data": { "stock": 99 } } ], "conditionScript": "return readResults['products/product1'].data.stock > 0;" }
Field Value Operations
firestore-increment-field
Atomically increment a numeric field
{ "documentPath": "stats/daily", "field": "visitCount", "incrementBy": 1 }firestore-array-union
Add elements to an array without duplicates
{ "documentPath": "users/user123", "field": "tags", "elements": ["premium", "verified"] }firestore-server-timestamp
Set fields to server timestamp
{ "documentPath": "users/user123", "fields": ["lastLogin", "modifiedAt"] }
Resources
The server also provides MCP resources for direct access to Firestore data:
firestore://collections- List all collectionsfirestore://collection/{collectionId}- Access collection datafirestore://collection/{collectionId}/document/{documentId}- Access document datafirestore://path/{path}- Access any path (collections or documents)
Examples
Basic CRUD Operations
// Create a new user
await client.callTool("firestore-create-document", {
collectionId: "users",
documentId: "user123",
data: {
name: "John Doe",
email: "john@example.com",
createdAt: new Date().toISOString()
}
});
// Update user data
await client.callTool("firestore-update-document", {
collectionId: "users",
documentId: "user123",
data: {
lastLogin: new Date().toISOString()
}
});
// Query active users
await client.callTool("firestore-query-collection", {
collectionId: "users",
filters: [
{ field: "status", operator: "==", value: "active" }
],
orderBy: { field: "createdAt", direction: "desc" },
limit: 10
});Working with Subcollections
// Create an order for a user
await client.callTool("firestore-create-document-by-path", {
collectionPath: "users/user123/orders",
data: {
items: ["widget1", "widget2"],
total: 99.99,
status: "pending"
}
});
// Get all orders for a user
await client.callTool("firestore-get-collection-by-path", {
collectionPath: "users/user123/orders"
});Batch Operations
// Atomic updates across multiple documents
await client.callTool("firestore-batch-write", {
operations: [
{
type: "update",
documentPath: "products/widget1",
data: { stock: 95 }
},
{
type: "create",
collectionPath: "orders",
data: {
product: "widget1",
quantity: 5,
userId: "user123"
}
},
{
type: "update",
documentPath: "users/user123",
data: { orderCount: 1 }
}
]
});Field Value Operations
// Increment a counter
await client.callTool("firestore-increment-field", {
documentPath: "stats/global",
field: "totalOrders",
incrementBy: 1
});
// Add tags without duplicates
await client.callTool("firestore-array-union", {
documentPath: "products/widget1",
field: "tags",
elements: ["bestseller", "featured"]
});
// Set server timestamp
await client.callTool("firestore-server-timestamp", {
documentPath: "logs/access",
fields: ["timestamp", "lastModified"]
});Security Best Practices
Use Minimal Permissions: Only grant access to collections and operations that are necessary
Default Deny: Set
defaultAllow: falsein production environmentsService Account Security: Protect your service account credentials
Environment Variables: Never commit credentials to version control
Audit Access: Regularly review permission configurations
Development
Running Tests
pnpm test
pnpm test:coverageBuilding
pnpm buildDocker
# Build image
docker build -t mcp-firestore .
# Run container
docker run -e FIRESTORE_PROJECT_ID=your-project mcp-firestoreTroubleshooting
Common Issues
Authentication Errors
Ensure
GOOGLE_APPLICATION_CREDENTIALSpoints to a valid service accountCheck that the service account has necessary Firestore permissions
Permission Denied
Verify collection is listed in permissions configuration
Check that the operation is allowed for the collection
Connection Issues
Confirm project ID is correct
Check network connectivity to Firestore
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
License
MIT License - see LICENSE for details.
Acknowledgments
Built on the Model Context Protocol by Anthropic.
Available Tools
23 toolsfirestore-array-removeC
Remove elements from an array field
Inputs: documentPath (required), field (required), elements (required).
firestore-array-unionC
Add elements to an array field without duplicates
Inputs: documentPath (required), field (required), elements (required).
firestore-batch-readC
Read multiple documents in a single operation
Inputs: documentPaths (required).
firestore-batch-writeB
Execute multiple write operations in a single atomic batch
Inputs: operations (required).
firestore-create-documentC
Create a new document in Firestore
Inputs: collectionId (required), data (required), documentId.
firestore-create-document-by-pathC
Create a document in a collection using full path (supports subcollections)
Inputs: collectionPath (required), data (required), documentId.
firestore-delete-documentC
Delete a document from Firestore
Inputs: collectionId (required), documentId (required).
firestore-delete-document-by-pathB
Delete a document using full path (supports subcollections)
Inputs: documentPath (required).
firestore-delete-fieldC
Delete specific fields from a document
Inputs: documentPath (required), fields (required).
firestore-field-value-batchC
Execute multiple field value operations in a batch
Inputs: operations (required).
firestore-get-collectionC
Get documents from a Firestore collection
Inputs: collectionId (required).
firestore-get-collection-by-pathC
Get documents from a collection using full path (supports subcollections)
Inputs: collectionPath (required).
firestore-get-documentC
Get a document from Firestore
Inputs: collectionId (required), documentId (required).
firestore-get-document-by-pathB
Get a document using full path (supports subcollections)
Inputs: documentPath (required).
firestore-increment-fieldB
Atomically increment a numeric field value
Inputs: documentPath (required), field (required), incrementBy (required).
firestore-list-collectionsB
List Firestore collections
Inputs: no named parameters.
firestore-list-subcollectionsC
List subcollections of a document
Inputs: documentPath (required).
firestore-query-collectionC
Query documents in a Firestore collection
Inputs: collectionId (required), filters (required), limit, orderBy.
firestore-query-collection-by-pathC
Query documents in a collection using full path (supports subcollections)
Inputs: collectionPath (required), filters (required), limit, orderBy.
firestore-server-timestampC
Set a field to the server timestamp
Inputs: documentPath (required), fields (required).
firestore-transactionC
Execute a transaction with read and write operations
Inputs: reads (required), operations (required), conditionScript.
firestore-update-documentC
Update an existing Firestore document
Inputs: collectionId (required), documentId (required), data (required).
firestore-update-document-by-pathC
Update a document using full path (supports subcollections)
Inputs: documentPath (required), data (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Most tools have distinct purposes, but there is some overlap between 'firestore-get-collection' and 'firestore-query-collection' (both retrieve documents from a collection), and between 'firestore-create-document' and 'firestore-create-document-by-path' (both create documents, differing only in path specification). Descriptions clarify these differences, but an agent might occasionally misselect between the overlapping pairs.
All tool names follow a consistent 'firestore-verb-noun' pattern with hyphens, using clear verbs like 'create', 'get', 'update', 'delete', 'list', 'query', and 'increment'. The naming is highly predictable and readable throughout the set.
With 23 tools, the count is borderline high for a database server, potentially feeling heavy. However, it covers both basic CRUD operations and advanced Firestore-specific features like array updates, transactions, and batch operations, which justifies the number but may overwhelm agents.
The tool set provides comprehensive coverage for Firestore operations, including full CRUD lifecycle, batch and transaction support, field-specific updates (e.g., array operations, increments), and path-based variants for subcollections. No obvious gaps exist for typical agent workflows in this domain.
Related MCP Connectors
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Managed MCP gateway with OAuth, per-agent permissions, shared accounts and activity logs.
Hosted remote MCP for protected account access, permissions, activity history and supported undo.
One MCP URL for all your connectors — scoped writes, enforced constraints, and a full audit trail.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables large language models like Claude to perform comprehensive interactions with Firebase Firestore databases, supporting full CRUD operations, complex queries, and advanced features like transactions and TTL management.16 npm4MIT
- FlicenseNot gradedqualityDmaintenanceA bridge that enables Large Language Models to read from and write to Firebase Firestore collections through Model Context Protocol (MCP) tools.1-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents and LLMs to securely interact with Firestore databases through complete CRUD operations (get, set, add, delete, query) while respecting Firestore Security Rules via the Firebase Client SDK.1MIT
- AlicenseAqualityDmaintenanceAn MCP server that enables interaction with Google Firestore in Datastore mode for entity management and querying. It provides tools for CRUD operations, aggregation queries, and transaction execution within Google Cloud projects.11MIT