Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Connetti il tuo IDE a Firestore utilizzando MCP Toolbox
Questa pagina descrive come utilizzare MCP Toolbox for databases per connettere l'istanza Firestore a ambienti di sviluppo integrati (IDE) e strumenti per sviluppatori che supportano il Model Context Protocol (MCP). Utilizza questi strumenti per eseguire query e interagire con il database. Questa guida è rivolta agli sviluppatori che utilizzano gli IDE e gli strumenti per sviluppatori esistenti per lavorare con Firestore.
Il Model Context Protocol (MCP) è un protocollo aperto per connettere i modelli linguistici di grandi dimensioni (LLM) a origini dati come Firestore. Questa pagina descrive come utilizzare MCP Toolbox for Databases per esporre gli strumenti di assistenza per sviluppatori a un'istanza Firestore utilizzando i seguenti IDE:
Esegui gcloud auth application-default login per l'autenticazione
Installare MCP Toolbox
Scarica l'ultima versione di MCP Toolbox come file binario. Seleziona il file binario corrispondente al tuo sistema operativo e all'architettura della CPU. Devi utilizzare MCP Toolbox versione V0.13.0 o successive.
Il tuo strumento di AI è ora connesso a Firestore utilizzando MCP. Prova a chiedere all'assistente
AI di elencare le raccolte, recuperare documenti, eseguire query sulle raccolte o gestire
le regole di sicurezza.
Sono disponibili i seguenti strumenti per il LLM:
firestore-add-documents: aggiungi un documento a un percorso di raccolta Firestore.
firestore-get-documents: recupera più documenti da Firestore in base ai relativi percorsi.
firestore-list-collections: elenca le raccolte Firestore per un determinato percorso principale.
firestore-delete-documents: elimina più documenti da Firestore.
firestore-query-collection: esegui query sui documenti di una raccolta con opzioni di filtro, ordinamento e limite.
firestore-get-rules: recupera le regole di sicurezza di Firestore attive per il progetto corrente.
firestore-update-document: aggiorna un documento esistente in Firestore in base al relativo percorso.
firestore-validate-rules: convalida la sintassi e gli errori delle regole di sicurezza di Firestore.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["Connect your IDE to Firestore using MCP Toolbox\n\nThis page describes how to use the [MCP Toolbox for databases](https://github.com/googleapis/genai-toolbox) to connect your Firestore instance to integrated development environments (IDE) and developer tools that support [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction). Use these tools to execute queries and interact with your database. This guide is for developers who use their existing IDEs and developer tools to work with Firestore.\n\n[Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) is an open protocol for connecting large language models (LLMs) to data sources like Firestore. This page describes how to use the [MCP Toolbox for Databases](https://github.com/googleapis/genai-toolbox) to expose your developer assistance tools to a Firestore instance using the following IDEs:\n\n- [Cursor](#configure-your-mcp-client)\n- [Windsurf](#configure-your-mcp-client) (Codium)\n- [Visual Studio Code](#configure-your-mcp-client) (Copilot)\n- [Cline](#configure-your-mcp-client) (VS Code extension)\n- [Claude desktop](#configure-your-mcp-client)\n- [Claude code](#configure-your-mcp-client)\n- [Gemini CLI](#configure-your-mcp-client)\n- [Gemini Code Assist](#configure-your-mcp-client)\n\nSet up Firestore\n\n1. [Create a new Google Cloud project](/resource-manager/docs/creating-managing-projects) or [select an existing one](/resource-manager/docs/creating-managing-projects#identifying_projects).\n\n2. [Enable the Firestore API](https://console.cloud.google.com/apis/library/firestore.googleapis.com) for your project.\n\n3. [Create a Firestore database](/firestore/docs/create-database-web-mobile-client-library) if you haven't already.\n\n4. Set up authentication for your local environment.\n\n - [Install gcloud CLI](/sdk/docs/install)\n - Run `gcloud auth application-default login` to authenticate\n\nInstall MCP Toolbox\n\n1. Download the latest version of MCP Toolbox as a binary. Select the [binary](https://github.com/googleapis/genai-toolbox/releases) corresponding to your operating system (OS) and CPU architecture. You must use MCP Toolbox version V0.13.0 or later.\n\n linux/amd64 \n\n ```\n curl -O https://storage.googleapis.com/genai-toolbox/version/linux/amd64/toolbox\n ```\n\n Replace \u003cvar translate=\"no\"\u003eversion\u003c/var\u003e with the MCP Toolbox\n version number, for example `v0.13.0`.\n\n darwin/arm64 \n\n ```\n curl -O https://storage.googleapis.com/genai-toolbox/version/darwin/arm64/toolbox\n ```\n\n Replace \u003cvar translate=\"no\"\u003eversion\u003c/var\u003e with the MCP Toolbox\n version number, for example `v0.13.0`.\n\n darwin/amd64 \n\n ```\n curl -O https://storage.googleapis.com/genai-toolbox/version/darwin/amd64/toolbox\n ```\n\n Replace \u003cvar translate=\"no\"\u003eversion\u003c/var\u003e with the MCP Toolbox\n version number, for example `v0.13.0`.\n\n windows/amd64 \n\n ```\n curl -O https://storage.googleapis.com/genai-toolbox/version/windows/amd64/toolbox\n ```\n\n Replace \u003cvar translate=\"no\"\u003eversion\u003c/var\u003e with the MCP Toolbox\n version number, for example `v0.13.0`.\n2. Make the binary executable.\n\n chmod +x toolbox\n\n3. Verify the installation.\n\n ./toolbox --version\n\nConfigure the MCP client \n\nClaude code\n\n1. Install [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview).\n2. Create the `.mcp.json` file in your project root, if it doesn't exist.\n3. Add the following configuration, replace the environment variables with your values, and save.\n\n\u003cbr /\u003e\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\n4. Restart Claude code to apply the new configuration.\n\nClaude desktop\n\n1. Open [Claude Desktop](https://claude.ai/download) and navigate to **Settings**.\n2. In the **Developer** tab, click **Edit Config** to open the configuration file.\n3. Add the following configuration, replace the environment variables with your values, and save.\n\n\u003cbr /\u003e\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\n4. Restart Claude Desktop.\n5. From the new chat screen, you should see a hammer (MCP) icon appear with the new MCP server available.\n\nCline\n\n1. Open the [Cline](https://github.com/cline/cline) extension in VS Code and tap **MCP Servers** icon.\n2. Click **Configure MCP Servers** to open the configuration file.\n3. Add the following configuration, replace the environment variables with your values, and save.\n\n\u003cbr /\u003e\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\nA green active status appears after the server connects successfully. \n\nCursor\n\n1. Create the `.cursor` directory in your project root if it doesn't exist.\n2. Create the `.cursor/mcp.json` file if it doesn't exist, and open it.\n3. Add the following configuration, replace the environment variables with your values, and save.\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\n4. Open [Cursor](https://www.cursor.com/) and navigate to **Settings \\\u003e Cursor Settings \\\u003e MCP**. A green active status appears when the server connects.\n\nVisual Studio Code (Copilot)\n\n1. Open [VS Code](https://code.visualstudio.com/docs/copilot/overview) and create `.vscode` directory in your project root if it does not exist.\n2. Create the `.vscode/mcp.json` file if it doesn't exist, and open it.\n3. Add the following configuration, replace the environment variables with your values, and save.\n\n```\n {\n \"servers\":{\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\nWindsurf\n\n1. Open [Windsurf](https://docs.codeium.com/windsurf) and navigate to Cascade assistant.\n2. Click the MCP icon, then click **Configure** to open the configuration file.\n3. Add the following configuration, replace the environment variables with your values, and save.\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\nGemini CLI\n\n1. Install the [Gemini CLI](https://github.com/google-gemini/gemini-cli?tab=readme-ov-file#quickstart).\n2. In your working directory, create a folder named `.gemini`. Within it, create a `settings.json` file.\n3. Add the following configuration, replace the environment variables with your values, and then save.\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\nGemini Code Assist\n\n1. Install the [Gemini Code Assist](https://marketplace.visualstudio.com/items?itemName=Google.geminicodeassist) extension in Visual Studio Code.\n2. Enable Agent Mode in Gemini Code Assist chat.\n3. In your working directory, create a folder named `.gemini`. Within it, create a `settings.json` file.\n4. Add the following configuration, replace the environment variables with your values, and then save.\n\n```\n {\n \"mcpServers\": {\n \"firestore\": {\n \"command\": \"./PATH/TO/toolbox\",\n \"args\": [\"--prebuilt\",\"firestore\",\"--stdio\"],\n \"env\": {\n \"FIRESTORE_PROJECT\": \"PROJECT_ID\",\n \"FIRESTORE_DATABASE\": \"DATABASE_NAME\"\n }\n }\n }\n }\n```\n\nUse the tools\n\nYour AI tool is now connected to Firestore using MCP. Try asking your AI\nassistant to list collections, get documents, query collections, or manage\nsecurity rules.\n\nThe following tools are available to the LLM:\n\n- **firestore-add-documents**: Add document to a Firestore collection path.\n- **firestore-get-documents**: Gets multiple documents from Firestore by their paths.\n- **firestore-list-collections**: List Firestore collections for a given parent path.\n- **firestore-delete-documents**: Delete multiple documents from Firestore.\n- **firestore-query-collection**: Query documents from a collection with filtering, ordering, and limit options.\n- **firestore-get-rules**: Retrieves the active Firestore security rules for the current project.\n- **firestore-update-document**: Update an existing document in Firestore by its path.\n- **firestore-validate-rules**: Validates Firestore security rules syntax and errors.\n\n| **Note:** Prebuilt tools are pre-1.0, so expect some tool changes between versions. LLMs will adapt to the tools available, so this doesn't affect most users."]]