This document outlines the integration with Google Gemini CLI, including version requirements, authentication, and feature implementation.
This MCP server is optimized for Gemini CLI v0.22.2 or later.
Check your version:
gemini --versionUpgrade if needed:
npm update -g @google/gemini-cligemini
# Follow prompts to login with Google accountFree tier limits:
- 60 requests/minute
- 1000 requests/day
export GEMINI_API_KEY="your-api-key"Get an API key from Google AI Studio.
1. Environment Variable (Recommended):
export GEMINI_MODEL="gemini-3-pro-preview"2. Settings File:
mkdir -p ~/.gemini
echo '{"model": {"name": "gemini-3-pro-preview"}}' > ~/.gemini/settings.json3. Project Settings:
echo '{"model": {"name": "gemini-3-pro-preview"}}' > .gemini/settings.jsonSettings applied in order (highest priority last):
- Default values
- User settings (
~/.gemini/settings.json) - Project settings (
.gemini/settings.json) - Environment variables (
GEMINI_MODEL) - Command-line arguments (
-m) - MCP tool
modelparameter
| Model | ID | Best For |
|---|---|---|
| Gemini 3 Pro | gemini-3-pro-preview |
Most capable, complex reasoning |
| Gemini 3 Flash | gemini-3-flash-preview |
Fast responses, good quality |
| Gemini 2.5 Flash-Lite | gemini-2.5-flash-lite |
Fastest, lightweight |
The MCP server passes file references directly to Gemini CLI:
# MCP tool call
{ "prompt": "Analyze @src/main.js" }
# Translates to
gemini "Analyze @src/main.js"Supported patterns:
@file.js- Single file@src/*.ts- Glob pattern@.- Current directory
When sandbox: true is passed to ask-gemini:
gemini -s "your prompt"Enables safe code execution in isolated environment.
When yolo: true is passed:
gemini --yolo "your prompt"Auto-approves ALL tool executions without confirmation prompts. Required for any Gemini CLI extension that needs tool approval.
Gemini CLI supports extensions that add new capabilities. Extensions may require yolo: true to auto-approve their tool calls.
Installing Extensions:
# Install from GitHub URL
gemini extensions install https://github.com/gemini-cli-extensions/workspace
# Or from local path
gemini extensions install /path/to/extensionPopular Extensions:
| Extension | Description | URL |
|---|---|---|
| Google Workspace | Gmail, Drive, Sheets, Docs, Calendar, Chat | https://github.com/gemini-cli-extensions/workspace |
Usage with MCP:
{
"prompt": "Search my Google Drive for 'budget' files and summarize them",
"yolo": true
}{
"prompt": "Read the latest emails from my inbox",
"yolo": true
}
⚠️ Security Note: Withoutyolo: true, extension tools will hang waiting for user approval. The YOLO flag bypasses all confirmations, so use with trusted inputs only. Never use with untrusted emails or documents (indirect prompt injection risk).
When changeMode: true is passed:
gemini --change-mode "your prompt"Returns structured edits in **FILE: path:line** format with OLD/NEW blocks.
The search tool uses Gemini's built-in Google Search grounding:
gemini --search "your query"Returns real-time information with source attribution.
The analyze-media tool handles various file types:
gemini "Analyze this image" < image.pngSupports images, PDFs, and other media formats.
When quota is exceeded on gemini-3-pro-preview:
- Server detects quota error
- Automatically retries with
gemini-3-flash-preview - Returns result with fallback notification
For long-running operations:
- Server sends progress notifications
- Keeps connection alive during processing
- Returns result when complete
npm install -g @google/gemini-cligemini # Login with Google
# OR
export GEMINI_API_KEY="your-key"- Wait for quota reset (typically 1 minute)
- Or use
gemini-3-flash-previewmodel - Or upgrade to paid API tier
- Use absolute paths when possible
- Verify file exists:
ls -la path/to/file - Check working directory
| Flag | Description | MCP Parameter |
|---|---|---|
-m <model> |
Select model | model |
-s |
Enable sandbox mode | sandbox |
--yolo |
Auto-approve all tool calls | yolo |
--change-mode |
Structured edit output | changeMode |
--search |
Enable web search | (used by search tool) |