Skip to main content
Glama
Gemini MCP Server

Gemini MCP Server

Gemini MCP Server

Python MCP License

A Model Context Protocol (MCP) server that provides Google Gemini AI capabilities to MCP-compatible clients like Claude Desktop and Claude Code.

Overview

This MCP server acts as a bridge between MCP clients and Google Gemini models, enabling:

  • Multi-turn conversations with session management

  • File and image analysis with glob pattern support

  • Automatic model selection based on content length

  • Deep thinking mode with reasoning output

  • Google Search integration for up-to-date information

Related MCP server: Gemini Chat MCP

Prerequisites

1. AIStudioProxyAPI Backend

This MCP server requires AIStudioProxyAPI as the backend service.

# Clone and setup AIStudioProxyAPI
git clone https://github.com/CJackHwang/AIstudioProxyAPI.git
cd AIstudioProxyAPI
poetry install
poetry run python launch_camoufox.py --headless

The API will be available at http://127.0.0.1:2048 by default.

2. uv Package Manager

# Install uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh

Installation

# Clone this repository
git clone https://github.com/YOUR_USERNAME/aistudio-gemini-mcp.git
cd aistudio-gemini-mcp

# Install dependencies
uv sync

Configuration

Environment Variables

Variable

Default

Description

GEMINI_API_BASE_URL

http://127.0.0.1:2048

AIStudioProxyAPI endpoint

GEMINI_API_KEY

(empty)

Optional API key

GEMINI_PROJECT_ROOT

$PWD

Root directory for file resolution

Claude Desktop / Claude Code

Add to ~/.claude/mcp.json:

{
  "mcpServers": {
    "gemini": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/aistudio-gemini-mcp", "python", "server.py"],
      "env": {
        "GEMINI_API_BASE_URL": "http://127.0.0.1:2048"
      }
    }
  }
}

Tools

gemini_chat

Send a message to Google Gemini with optional file attachments.

Parameter

Type

Required

Description

prompt

string

Yes

Message to send (1-100,000 chars)

file

list[string]

No

File paths or glob patterns

session_id

string

No

Session ID ("last" for recent)

model

string

No

Override model selection

system_prompt

string

No

System context

temperature

float

No

Sampling temperature (0.0-2.0)

max_tokens

int

No

Max response tokens

response_format

enum

No

"markdown" or "json"

Examples:

# Simple query
gemini_chat(prompt="Explain quantum computing")

# With file
gemini_chat(prompt="Review this code", file=["main.py"])

# With image
gemini_chat(prompt="Describe this", file=["photo.png"])

# Continue conversation
gemini_chat(prompt="Tell me more", session_id="last")

# Multiple files
gemini_chat(prompt="Analyze", file=["src/**/*.py"])

gemini_list_models

List available Gemini models.

Parameter

Type

Required

Description

filter_text

string

No

Filter models by name

response_format

enum

No

"markdown" or "json"

Model Selection

Auto-selects model based on content length:

Content Size

Model

≤ 8,000 chars

gemini-3-pro-preview

> 8,000 chars

gemini-2.5-pro

Fallback

gemini-2.5-flash

Features

Session Management

  • Automatic session creation

  • Use "last" to continue recent conversation

  • LRU eviction (max 50 sessions)

File Support

  • Images: PNG, JPG, JPEG, GIF, WebP, BMP

  • Text: Any text-based file with auto-encoding detection

  • Glob patterns: *.py, src/**/*.ts, etc.

Built-in Capabilities

  • reasoning_effort: high - Deep thinking mode

  • google_search - Web search integration

  • Automatic retry with model fallback

Running Standalone

# Start the MCP server
uv run python server.py

Project Structure

aistudio-gemini-mcp/
├── server.py           # MCP server implementation
├── pyproject.toml      # Project configuration
├── uv.lock             # Dependency lock file
├── README.md           # This file
├── LICENSE             # MIT License
└── mcp_config_example.json

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Available Tools

2 tools
gemini_chatA
Read-only
Send a message to Google Gemini and get a response.

Args:
    params (GeminiChatInput): Chat parameters including:
        - prompt (str): The prompt to send
        - file (Optional[list[str]]): Files to include (text, code, images)
        - session_id (Optional[str]): Session ID for multi-turn chat, use 'last' for recent
        - model (Optional[str]): Override model selection
        - system_prompt (Optional[str]): System context
        - temperature (Optional[float]): Creativity (0.0-2.0)
        - max_tokens (Optional[int]): Max response length
        - response_format: Output format - 'markdown' or 'json'

Returns:
    str: Response with SESSION_ID for continuation.

Examples:
    - Simple: prompt="What is AI?"
    - With file: prompt="Review", file=["main.py"]
    - With image: prompt="Describe", file=["photo.jpg"]
    - Continue: prompt="Tell me more", session_id="last"

Inputs: params (required). Returns: result

gemini_list_modelsB
Read-onlyIdempotent

List available Gemini models.

Inputs: params (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have completely distinct purposes with no overlap: gemini_chat handles chat interactions with the Gemini API, while gemini_list_models provides metadata about available models. An agent would never confuse these tools as they serve fundamentally different functions in the workflow.

    Naming Consistency5/5

    Both tools follow a consistent 'gemini_' prefix + descriptive_snake_case pattern (gemini_chat and gemini_list_models). This creates a predictable naming convention that clearly associates both tools with the Gemini service while maintaining readability and consistency throughout the toolset.

    Tool Count2/5

    With only 2 tools, this server feels severely under-equipped for a comprehensive Gemini API integration. While chat functionality is essential, the absence of tools for embeddings, file analysis, or other Gemini capabilities creates a thin surface that will limit agent effectiveness. The count is too low for the apparent scope of a full Gemini MCP server.

    Completeness2/5

    The tool surface is significantly incomplete for a Gemini integration server. While chat functionality is well-implemented, there are major gaps: no tools for embeddings generation, file content analysis beyond chat context, model information beyond listing, or other Gemini API endpoints. This creates dead ends for agents trying to perform common Gemini workflows beyond basic chat interactions.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables interaction with Google's Gemini AI models including file uploads, conversation management, and batch API processing for large-scale tasks at reduced costs. Supports multiple Gemini models with advanced features like embeddings generation and automated workflow processing.
      21
      95 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables chatting with Google Gemini AI models and custom Gems, supporting text and image generation with automatic cookie synchronization via Chrome extension.
      3
      -
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI-powered web searches using Google's Gemini 2.5 models with Google Search Grounding. Supports multiple Gemini models (Flash, Flash-Lite, Pro) with configurable thinking budget and web search capabilities.
      1
      13 npm
      2
      MIT