The Firebase MCP Server provides a unified interface to interact with various Firebase services including Authentication, Firestore, and Storage. This server implements the Model Context Protocol (MCP) to standardize access to Firebase's core functionalities.
To set up the Firebase MCP Server, follow these steps:
Clone the repository and build the project:
git clone https://github.com/gemini-dk/mcp-server-firebase
cd mcp-server-firebase
npm install
npm run build
Obtain your Firebase service account key:
Configure the MCP settings by creating a mcp_settings.json
file:
{
"firebase-mcp": {
"command": "node",
"args": [
"/path/to/mcp-server-firebase/dist/index.js"
],
"env": {
"SERVICE_ACCOUNT_KEY_PATH": "/path/to/serviceAccountKey.json"
}
}
}
Be sure to replace:
/path/to/mcp-server-firebase
with the actual directory path where you cloned the repository/path/to/serviceAccountKey.json
with the path to your Firebase service account key fileThe server provides access to several Firebase services through a unified API interface:
You can retrieve user information using ID or email:
// Example of getting a user by email
const userResponse = await mcpClient.send({
model: "firebase-auth",
action: "getUser",
params: {
email: "[email protected]"
}
});
// Example of getting a user by ID
const userResponse = await mcpClient.send({
model: "firebase-auth",
action: "getUser",
params: {
uid: "user123"
}
});
The server supports common Firestore operations:
// Adding/updating a document
const addResponse = await mcpClient.send({
model: "firebase-firestore",
action: "setDoc",
params: {
collection: "users",
docId: "user123",
data: {
name: "John Doe",
email: "[email protected]"
}
}
});
// Listing documents in a collection
const listResponse = await mcpClient.send({
model: "firebase-firestore",
action: "listDocs",
params: {
collection: "users"
}
});
// Deleting a document
const deleteResponse = await mcpClient.send({
model: "firebase-firestore",
action: "deleteDoc",
params: {
collection: "users",
docId: "user123"
}
});
Access and manage files in Firebase Storage:
// List files in a directory
const filesResponse = await mcpClient.send({
model: "firebase-storage",
action: "listFiles",
params: {
path: "images/"
}
});
// Get file metadata and download URL
const fileInfoResponse = await mcpClient.send({
model: "firebase-storage",
action: "getFileInfo",
params: {
path: "images/profile.jpg"
}
});
You can customize your Firebase MCP Server by adding additional environment variables to the env
section of your mcp_settings.json
file:
"env": {
"SERVICE_ACCOUNT_KEY_PATH": "/path/to/serviceAccountKey.json",
"FIREBASE_DATABASE_URL": "https://your-project-id.firebaseio.com",
"STORAGE_BUCKET": "your-project-id.appspot.com"
}
These settings allow you to specify which Firebase project and resources the MCP server will connect to.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.