Connect to Model Context Protocol (MCP) servers Stay organized with collections Save and categorize content based on your preferences.
MCP servers provideGemini with additional tools and datasources. For example, by adding theFirebase MCP server,you can use natural language to explore yourCloud Firestore data whilebuilding or debugging your application.
Caution: Adding an MCP server to your workspace gives it permission to run codeand potentially modify your app. Only add MCP servers from trusted sources.Prerequisites
If required by the MCP server, ensure you have a working installation of Node.jsand npm.
Choose a compatible MCP server
Firebase Studio has foundational support for MCP servers, but not all MCPservers are compatible. When choosing an MCP server, keep the followingcompatibility details in mind:
Supported:
- Standard input/output (stdio) or Server-Sent Events (SSE)/Streamable HTTPtransport servers
- API key authentication using HTTP headers or environment variables
- Tools provided by MCP servers
Not supported:
- Servers that require a graphical user interface or a desktop session
- Prompts, sampling, or other resources provided by MCP servers
.env
file.Add an MCP server
To add an MCP server, you need to create or edit its configuration file.
- For your first server:Create the configuration file.
- To add or adjust servers:Edit the server configuration.
Step 1: Create the configuration file
Interactive chat andGemini CLI can both connect to MCPservers, but use different configuration files:
- Interactive chat uses
.idx/mcp.json
. - Gemini CLI uses
.gemini/settings.json
.
Create one or both files using the following instructions.
Interactive chat
InCode view, create.idx/mcp.json
usingone of these methods:
- Command Palette: Open the Command Palette (
Shift+Ctrl+P
), and use theFirebase Studio: Add MCP Server command. - Interactive chat: Click
Customize Tools in interactive chat and selectAdd MCP server.
- Explorer: From Explorer
(Ctrl+Shift+E)
, right-click the.idx
directory and selectNew file. Name the filemcp.json
.
Gemini CLI
InCode view, create.gemini/settings.json
:
- In Explorer
(Ctrl+Shift+E)
, check if the.gemini
directory exists. Ifnot, right-click the Explorer pane and selectNew folder. Name thefolder.gemini
. - Right-click the
.gemini
directory and selectNew file. Name the filesettings.json
.
For details about using MCP servers with Gemini CLI,review the fulldocumentation.
Step 2: Edit the server configuration
Open the server configuration file.
Tip: To quickly open.idx/mcp.json
, clickCustomize Tools in interactive chat and selectEditConfig.
Add the server configuration to the content of the file. For example, to addthe Firebase MCP server, enter:
{"mcpServers":{"firebase":{"command":"npx","args":["-y","firebase-tools@latest","experimental:mcp"]}}}
This configuration file instructsGemini which MCP serveryou want it to use. This example shows a single server called
firebase
that will use thenpx
command to install and runfirebase-tools@latest
.If your MCP server requires API key authentication, you can configure it inone of the following ways:
For remote HTTP MCP servers that require an API key in request headers,use the
headers
field. For example, to configure GitHub's MCP server:{"mcpServers":{"github":{"url":"https://api.githubcopilot.com/mcp/","headers":{"Authorization":"Bearer <ACCESS_TOKEN>"}}}}
For local stdio MCP servers that require an API key in environmentvariables, use the
env
field. For example, to configure a local buildof GitHub's MCP server:{"mcpServers":{"github":{"command":"/path/to/github-mcp-server","args":["stdio"],"env":{"GITHUB_PERSONAL_ACCESS_TOKEN":"<ACCESS_TOKEN>"}}}}
To avoid hardcoding secrets in
mcp.json
, you can optionally use the${env:VARIABLE_NAME}
syntax. This will substitute in values fromenvironment variables defined in a.env
or.env.local
file in yourworkspace root. For example:{"mcpServers":{"github":{"url":"https://api.githubcopilot.com/mcp/","headers":{"Authorization":"Bearer ${env:GITHUB_ACCESS_TOKEN}"}}}}
In the terminal (
Shift+Ctrl+C
), run any necessary commands to completeinstallation. For example, to use the Firebase MCP server, enter thefollowing command to sign in to your account:firebase login --no-localhost
Follow the instructions in the terminal to authorize the session. Sometools require a connected Firebase project. You can use theFirebase MCP server to create a project, or you canrun the following command to initialize a Firebase project:
firebase init
This creates a
firebase.json
file in your root directory.
Use MCP tools
After installing the MCP server you want to use, the tools or data it providesare available in:
- Gemini CLI
- Interactive chat when using Agent mode and Agent (Auto-run)modes
- theApp Prototyping agent
For example, if you add the Firebase MCP server, you could askGemini to fetch the SDK config for the current project,retrieve data stored inCloud Firestore andRealtime Database, help you set upFirebase services,and more.
In interactive chat, type/
to see a list of availableMCP prompts.
Check or adjust tools
You can manage which tools are active in interactive chat:
- Click
Customize Tools in interactive chat to see a list ofall available tools from your configured MCP servers.
- Use the checkboxes to enable or disable an entire server or individual tools.
Troubleshoot MCP servers
If you encounter issues with an MCP server, use these steps to diagnose theproblem.
Check the logs for errors
- Open the Output panel (
Shift+Ctrl+U
). - In the drop-down menu, selectGemini.
- Check for messages that begin with an
[MCPManager]
tag. These logs showwhich servers are configured, which tools were successfully added, and anyerror messages.
Rebuild the environment
If an MCP server fails to install or connect, try rebuilding your workspace:
- Open the Command Palette (
Shift+Ctrl+P
). - Run theFirebase Studio: Rebuild Environment command.
- After the workspace rebuilds, check if the MCP server connects.
If tools aren't being used
If the MCP server connects butGemini doesn't use its tools:
- Start a new chat session: This ensuresGemini picks up thelatest tool configuration.Learn how to manage chat history.
- Be specific in your prompt: IfGemini can accomplish thetask without using an MCP tool, it might attempt a different method. If youwant to use a specific tool, try naming the tool. For example: "Use
firebase_get_sdk_config
to get the SDK config for the current project." - Join the Google Developer Program:Check if your account is enrolled.
Next steps
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-24 UTC.