Gemini Python SDK
Googleās Gemini Python SDK can use FastMCP clients directly.Googleās MCP integration is currently experimental and available in the Python and JavaScript SDKs. The API automatically calls MCP tools when needed and can connect to both local and remote MCP servers.
Currently, Geminiās MCP support only accesses tools from MCP serversāit queries the
list_tools
endpoint and exposes those functions to the AI. Other MCP features like resources and prompts are not currently supported.Create a Server
First, create a FastMCP server with the tools you want to expose. For this example, weāll create a server with a single tool that rolls dice.server.py
Call the Server
To use the Gemini API with MCP, youāll need to install the Google Generative AI SDK:GEMINI_API_KEY
environment variable. Consult the Gemini SDK documentation for more information.
Remote & Authenticated Servers
In the above example, we connected to our local server usingstdio
transport. Because weāre using a FastMCP client, you can also connect to any local or remote MCP server, using any transport or auth method supported by FastMCP, simply by changing the client configuration.
For example, to connect to a remote, authenticated server, you can use the following client: