This MCP Gemini Server provides a bridge between MCP-compatible systems and Google's Gemini models through a standardized tool-based interface. It allows other LLMs like Cline to leverage Gemini's capabilities as a backend workhorse.
To automatically install Gemini Server for Claude Desktop:
npx -y @smithery/cli install @bsmi021/mcp-gemini-server --client claude
npm install
npm run build
{
"mcpServers": {
"gemini-server": {
"command": "node",
"args": ["/path/to/mcp-gemini-server/dist/server.js"],
"env": {
"GOOGLE_GEMINI_API_KEY": "YOUR_API_KEY",
"GOOGLE_GEMINI_MODEL": "gemini-1.5-flash"
},
"disabled": false,
"autoApprove": []
}
}
}
Configure the server using environment variables passed via the env
object:
gemini-1.5-flash
)gemini_generateContent
prompt
(string)modelName
, generationConfig
, safetySettings
gemini_generateContentStream
prompt
(string)modelName
, generationConfig
, safetySettings
prompt
(string), functionDeclarations
(array)modelName
, generationConfig
, safetySettings
, toolConfig
gemini_startChat
modelName
, history
, tools
, generationConfig
, safetySettings
gemini_sendMessage
sessionId
(string), message
(string)generationConfig
, safetySettings
, tools
, toolConfig
gemini_sendFunctionResult
sessionId
(string), functionResponses
(array)generationConfig
, safetySettings
gemini_uploadFile
filePath
(string - must be an absolute path)displayName
, mimeType
gemini_listFiles
pageSize
, pageToken
gemini_getFile
fileName
(string - e.g., files/abc123xyz
)gemini_deleteFile
fileName
(string)gemini_createCache
contents
(array)modelName
, displayName
, systemInstruction
, ttl
gemini_listCaches
pageSize
, pageToken
gemini_getCache
cacheName
(string)gemini_updateCache
cacheName
(string)ttl
, displayName
gemini_deleteCache
cacheName
(string)<use_mcp_tool>
<server_name>gemini-server</server_name>
<tool_name>gemini_generateContent</tool_name>
<arguments>
{
"prompt": "Write a short poem about a rubber duck."
}
</arguments>
</use_mcp_tool>
<use_mcp_tool>
<server_name>gemini-server</server_name>
<tool_name>gemini_generateContent</tool_name>
<arguments>
{
"modelName": "gemini-1.0-pro",
"prompt": "Explain the concept of recursion in programming.",
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 500
}
}
</arguments>
</use_mcp_tool>
Starting a chat:
<use_mcp_tool>
<server_name>gemini-server</server_name>
<tool_name>gemini_startChat</tool_name>
<arguments>
{}
</arguments>
</use_mcp_tool>
Sending a message:
<use_mcp_tool>
<server_name>gemini-server</server_name>
<tool_name>gemini_sendMessage</tool_name>
<arguments>
{
"sessionId": "some-uuid-123",
"message": "Hello! Can you tell me about the Gemini API?"
}
</arguments>
</use_mcp_tool>
<use_mcp_tool>
<server_name>gemini-server</server_name>
<tool_name>gemini_uploadFile</tool_name>
<arguments>
{
"filePath": "C:\\Users\\YourUser\\Documents\\my_document.txt",
"displayName": "My Document"
}
</arguments>
</use_mcp_tool>
The server returns structured errors using the MCP standard McpError
type, containing:
code
: Error type (e.g., InvalidParams
, InternalError
)message
: Human-readable descriptiondetails
: Additional information from the Gemini SDKCommon error scenarios include:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "gemini-server" '{"command":"node","args":["/path/to/mcp-gemini-server/dist/server.js"],"env":{"GOOGLE_GEMINI_API_KEY":"YOUR_API_KEY","GOOGLE_GEMINI_MODEL":"gemini-1.5-flash"},"disabled":false,"autoApprove":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"gemini-server": {
"command": "node",
"args": [
"/path/to/mcp-gemini-server/dist/server.js"
],
"env": {
"GOOGLE_GEMINI_API_KEY": "YOUR_API_KEY",
"GOOGLE_GEMINI_MODEL": "gemini-1.5-flash"
},
"disabled": false,
"autoApprove": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"gemini-server": {
"command": "node",
"args": [
"/path/to/mcp-gemini-server/dist/server.js"
],
"env": {
"GOOGLE_GEMINI_API_KEY": "YOUR_API_KEY",
"GOOGLE_GEMINI_MODEL": "gemini-1.5-flash"
},
"disabled": false,
"autoApprove": []
}
}
}
3. Restart Claude Desktop for the changes to take effect