loading…
Search for a command to run...
loading…
MCP FirestoreDB - Google Firestore MCP Server for database operations and CRUD functionality
MCP FirestoreDB - Google Firestore MCP Server for database operations and CRUD functionality
License: MIT npm version Downloads Node.js Version TypeScript Google Cloud Firestore MCP Protocol Claude Desktop Cursor IDE Trae AI
A comprehensive Model Context Protocol (MCP) server for Google Cloud Firestore database operations. This server provides 12 powerful tools for document database management, collection operations, and data querying through the MCP protocol.
This MCP server provides 17 optimized tools with short, intuitive names for efficient Firestore operations:
📝 Document Operations (5 tools):
create_doc - Create new documentsget_doc - Retrieve specific documentsget_docs - Query multiple documents with filteringupdate_doc - Update existing documentsdelete_doc - Remove documents🔄 Batch Operations (3 tools):
batch_create - Create multiple documents at oncebatch_update - Update multiple documents simultaneouslybatch_delete - Delete multiple documents in batch📊 Collection Management (4 tools):
list_collections - List all available collectionscollection_stats - Get detailed collection statisticsanalyze_schema - Analyze document schemas and structuredelete_collection - Remove entire collections (with caution)🔍 Index Management (5 tools):
create_index - Generate composite index configurationslist_indexes - Get guidance on listing existing indexesget_index_status - Check index building status and informationparse_index_error - Parse Firestore error messages for index creationgenerate_indexes_config - Generate firestore.indexes.json for deployment| Variable | Description | Example |
|---|---|---|
GOOGLE_APPLICATION_CREDENTIALS |
Path to service account JSON file | /path/to/service-account.json |
FIREBASE_PROJECT_ID |
Firebase/GCP Project ID | my-project-id |
| Variable | Description | Default |
|---|---|---|
FIRESTORE_DATABASE_ID |
Firestore database ID | (default) |
FIRESTORE_EMULATOR_HOST |
Firestore emulator host for local development | localhost:8080 |
DEBUG_FIRESTORE |
Enable debug logging | false |
The easiest and most reliable way! No installation or build needed - just configure and use:
{
"mcpServers": {
"firestoredb": {
"command": "npx",
"args": ["-y", "[email protected]"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"FIREBASE_PROJECT_ID": "my-firebase-project",
"FIRESTORE_DATABASE_ID": "(default)"
}
}
}
}
Benefits:
__dirname error)Use the development version directly from GitHub:
{
"mcpServers": {
"firestoredb": {
"command": "npx",
"args": ["-y", "hendrickcastro/MCPFirestoreDB"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"FIREBASE_PROJECT_ID": "my-firebase-project",
"FIRESTORE_DATABASE_ID": "(default)"
}
}
}
}
git clone <your-repo-url>
cd MCPFirestoreDB
npm install && npm run build
Then configure with local path:
{
"mcpServers": {
"mcp-firestoredb": {
"command": "node",
"args": ["path/to/MCPFirestoreDB/dist/server.js"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"FIREBASE_PROJECT_ID": "your-project-id"
}
}
}
}
MCP FirestoreDB provides 12 comprehensive tools for Google Cloud Firestore operations:
create_docCreate a new document in a Firestore collection.
Parameters:
collection_path: Collection path (e.g., "users" or "users/123/orders")document_id: Optional document ID (auto-generated if not provided)data: Document data objectget_docRetrieve a specific document by ID from a collection.
Parameters:
collection_path: Collection pathdocument_id: Document ID to retrieveget_docsGet multiple documents with optional filtering and pagination.
Parameters:
collection_path: Collection pathlimit: Maximum number of documents (default: 100)order_by: Field to order byorder_direction: Order direction ("asc" or "desc")where_conditions: Array of where conditions [field, operator, value]start_after: Document ID for paginationupdate_docUpdate an existing document in a collection.
Parameters:
collection_path: Collection pathdocument_id: Document ID to updatedata: Data to update (partial update supported)merge: Whether to merge with existing data (default: true)delete_docDelete a document from a collection.
Parameters:
collection_path: Collection pathdocument_id: Document ID to deletebatch_createCreate multiple documents in a single batch operation.
batch_updateUpdate multiple documents in a single batch operation.
batch_deleteDelete multiple documents in a single batch operation.
list_collectionsList all collections in the Firestore database.
Parameters:
parent_path: Optional parent document path for subcollectionscollection_statsGet statistics about a Firestore collection.
Parameters:
collection_path: Collection pathsample_size: Number of documents to sample (default: 100)analyze_schemaAnalyze the schema of documents in a collection.
Parameters:
collection_path: Collection pathsample_size: Number of documents to sample (default: 100)delete_collectionDelete an entire collection and all its documents (use with caution).
Parameters:
collection_path: Collection path to deletebatch_size: Documents to delete per batch (default: 100)// Create a document
const newDoc = await create_doc({
collection_path: "users",
document_id: "user-123",
data: {
name: "John Doe",
email: "[email protected]",
createdAt: new Date()
}
});
// Get a specific document
const document = await get_doc({
collection_path: "users",
document_id: "user-123"
});
// Update a document
const updated = await update_doc({
collection_path: "users",
document_id: "user-123",
data: { lastLogin: new Date() },
merge: true
});
// Get documents with filtering
const activeUsers = await get_docs({
collection_path: "users",
where_conditions: [
["status", "==", "active"],
["createdAt", ">", "2024-01-01"]
],
order_by: "createdAt",
order_direction: "desc",
limit: 50
});
// Get documents with pagination
const nextPage = await get_docs({
collection_path: "users",
limit: 10,
start_after: "last-document-id"
});
// Batch create multiple documents
const batchCreate = await batch_create({
operations: [
{
collection_path: "products",
document_id: "prod-1",
data: { name: "Product 1", price: 100 }
},
{
collection_path: "products",
document_id: "prod-2",
data: { name: "Product 2", price: 200 }
}
]
});
// List all collections
const collections = await list_collections();
// Get collection statistics
const stats = await collection_stats({
collection_path: "users",
sample_size: 1000
});
// Analyze collection schema
const schema = await analyze_schema({
collection_path: "products",
sample_size: 500
});
Production Environment:
{
"mcpServers": {
"firestoredb": {
"command": "npx",
"args": ["-y", "[email protected]"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/production-service-account.json",
"FIREBASE_PROJECT_ID": "my-production-project",
"FIRESTORE_DATABASE_ID": "(default)"
}
}
}
}
Development with Emulator:
{
"mcpServers": {
"firestoredb": {
"command": "npx",
"args": ["-y", "[email protected]"],
"env": {
"FIREBASE_PROJECT_ID": "demo-project",
"FIRESTORE_EMULATOR_HOST": "localhost:8080",
"DEBUG_FIRESTORE": "true"
}
}
}
}
Multiple Databases:
{
"mcpServers": {
"firestoredb-main": {
"command": "npx",
"args": ["-y", "[email protected]"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"FIREBASE_PROJECT_ID": "my-project",
"FIRESTORE_DATABASE_ID": "(default)"
}
},
"firestoredb-analytics": {
"command": "npx",
"args": ["-y", "[email protected]"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"FIREBASE_PROJECT_ID": "my-project",
"FIRESTORE_DATABASE_ID": "analytics-db"
}
}
}
}
Authentication Issues:
Connection Issues:
Query Issues:
Firestore Emulator Setup:
npm install -g firebase-toolsfirebase emulators:start --only firestoreFirestore index management tools help you handle composite indexes efficiently:
// Generate index configuration for complex queries
{
"collection_path": "users",
"fields": [
{"field": "status", "order": "ASCENDING"},
{"field": "created_at", "order": "DESCENDING"}
]
}
// Parse Firestore error messages to extract index creation links
{
"error_message": "The query requires an index. You can create it here: https://console.firebase.google.com/..."
}
// Check index building progress
{
"collection_path": "products",
"index_fields": ["category", "price"]
}
Important Notes:
firestore.indexes.json for deployment automationnpm install # Install dependencies
npm run build # Build project
npm test # Run tests
npm start # Development mode
Project Structure:
src/
├── tools/ # Tool implementations
│ ├── crudOperations.ts # CRUD operations
│ ├── collectionOperations.ts # Collection management
│ ├── indexOperations.ts # Index management operations
│ ├── types.ts # Type definitions
│ └── index.ts # Tool exports
├── db.ts # Firestore connection
├── server.ts # MCP server setup
└── tools.ts # Tool definitions
Key Features:
git checkout -b feature/name)npm test)git commit -m 'Add feature')MIT License - see LICENSE file for details.
Database: firestore google-cloud-firestore nosql document-database database-analysis database-tools google-cloud database-management database-operations data-analysis
MCP & AI: model-context-protocol mcp-server mcp-tools ai-tools claude-desktop cursor-ide anthropic llm-integration ai-database intelligent-database
Technology: typescript nodejs npm-package cli-tool database-client nosql-client database-sdk rest-api json-api database-connector
Features: collection-analysis document-operations batch-operations schema-analysis query-execution database-search data-exploration database-insights crud-operations real-time-database
Use Cases: database-development data-science business-intelligence database-migration schema-documentation performance-analysis data-governance database-monitoring troubleshooting automation
🎯 MCP FirestoreDB provides comprehensive Google Cloud Firestore database management through the Model Context Protocol. Perfect for developers and data analysts working with Firestore! 🚀
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mcpfirestoredb": {
"command": "npx",
"args": [
"-y",
"mcpfirestoredb"
]
}
}
}