Connect to Model Context Protocol (MCP) servers

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
Note: You can pass environment variables to MCP servers through the.env file.

Add an MCP server

To add an MCP server, you need to create or edit its configuration file.

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: ClickCustomize tools iconCustomize Tools in interactive chat and selectAdd MCP server.
  • Explorer: From Explorer(Ctrl+Shift+E), right-click the.idxdirectory and selectNew file. Name the filemcp.json.

Gemini CLI

InCode view, create.gemini/settings.json:

  1. In Explorer(Ctrl+Shift+E), check if the.gemini directory exists. Ifnot, right-click the Explorer pane and selectNew folder. Name thefolder.gemini.
  2. 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

  1. Open the server configuration file.

    Tip: To quickly open.idx/mcp.json, clickCustomize tools iconCustomize Tools in interactive chat and selectEditConfig.
  2. 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 calledfirebase 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 theheaders 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 theenv 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 inmcp.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}"}}}}
  3. 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 afirebase.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:

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.

List of available MCP prompts

Check or adjust tools

You can manage which tools are active in interactive chat:

  1. ClickCustomize tools iconCustomize Tools in interactive chat to see a list ofall available tools from your configured MCP servers.
  2. Use the checkboxes to enable or disable an entire server or individual tools.

List of available MCP tools

Troubleshoot MCP servers

If you encounter issues with an MCP server, use these steps to diagnose theproblem.

Check the logs for errors

  1. Open the Output panel (Shift+Ctrl+U).
  2. In the drop-down menu, selectGemini.
  3. 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:

  1. Open the Command Palette (Shift+Ctrl+P).
  2. Run theFirebase Studio: Rebuild Environment command.
  3. 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: "Usefirebase_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.