This integration focuses on running local FastMCP server files with STDIO transport. For remote servers running with HTTP or SSE transport, use your client's native configuration - FastMCP's integrations focus on simplifying the complex local setup with dependencies and uv commands.
Gemini CLI supports MCP servers through multiple transport methods including STDIO, SSE, and HTTP, allowing you to extend Gemini’s capabilities with custom tools, resources, and prompts from your FastMCP servers.
This integration uses STDIO transport to run your FastMCP server locally. For remote deployments, you can run your FastMCP server with HTTP or SSE transport and configure it directly using Gemini CLI’s built-in MCP management commands.
New in version 2.13.0The easiest way to install a FastMCP server in Gemini CLI is using the fastmcp install gemini-cli command. This automatically handles the configuration, dependency management, and calls Gemini CLI’s built-in MCP management system.
Copy
fastmcp install gemini-cli server.py
The install command supports the same file.py:object notation as the run command. If no object is specified, it will automatically look for a FastMCP server object named mcp, server, or app in your file:
Copy
# These are equivalent if your server object is named 'mcp'fastmcp install gemini-cli server.pyfastmcp install gemini-cli server.py:mcp# Use explicit object name if your server has a different namefastmcp install gemini-cli server.py:my_custom_server
The command will automatically configure the server with Gemini CLI’s gemini mcp add command.
FastMCP provides flexible dependency management options for your Gemini CLI servers:Individual packages: Use the --with flag to specify packages your server needs. You can use this flag multiple times:
Control the Python environment for your server with these options:Python version: Use --python to specify which Python version your server requires. This ensures compatibility when your server needs specific Python features:
Project directory: Use --project to run your server within a specific project context. This tells uv to use the project’s configuration files and virtual environment:
For more control over the configuration, you can manually use Gemini CLI’s built-in MCP management commands. This gives you direct control over how your server is launched:
Copy
# Add a server with custom configurationgemini mcp add dice-roller uv -- run --with fastmcp fastmcp run server.py# Add with environment variablesgemini mcp add weather-server -e API_KEY=secret -e DEBUG=true uv -- run --with fastmcp fastmcp run server.py# Add with specific scope (user, or project)gemini mcp add my-server --scope user uv -- run --with fastmcp fastmcp run server.py
You can also manually specify Python versions and project directories in your Gemini CLI commands:
Copy
# With specific Python versiongemini mcp add ml-server uv -- run --python 3.11 --with fastmcp fastmcp run server.py# Within a project directorygemini mcp add project-server uv -- run --project /path/to/project --with fastmcp fastmcp run server.py
Once your server is installed, you can start using your FastMCP server with Gemini CLI.Try asking Gemini something like:
“Roll some dice for me”
Gemini will automatically detect your roll_dice tool and use it to fulfill your request.Gemini CLI can now access all the tools and prompts you’ve defined in your FastMCP server.If your server provides prompts, you can use them as slash commands with /prompt_name.