Add an MCP server

Gemini in Android Studio's agent can interact with external tools using the Model Context Protocol (MCP). This feature provides a standardized way for Agent mode to use tools and extend knowledge and capabilities with the external environment.

There are many tools you can connect to the MCP Host in Android Studio. For example, you can integrate with the GitHub MCP Server to create pull requests directly from Android Studio. For more ideas, see the MCP example servers.

To add an MCP server, create a mcp.json file and place it in the configuration directory of Studio. The mcp.json file should follow this format:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ]
    },
    "sequential-thinking": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sequential-thinking"
      ]
    },
    "github": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}

Refer to the documentation for the MCP server you're integrating with for the precise command and args that you should list in this file. You might also need to install tools such as Node.js or Docker, depending on the MCP server's software requirements.

Limitations

There are a few important limitations to Android Studio's MCP integration:

  • MCP servers must implement the stdio transport.
  • The following functionalities aren't yet supported:
    • Streaming HTTP transport
    • MCP resources
    • Prompt templates