Gemini CLI Integration Guide
Overview
This document outlines the integration with Google Gemini CLI, including version requirements, authentication, and feature implementation.
Version Compatibility
Recommended Version: v0.22.2+
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-cliAuthentication
Method 1: Google Account (Recommended)
gemini
# Follow prompts to login with Google accountFree tier limits:
60 requests/minute
1000 requests/day
Method 2: API Key
Get an API key from Google AI Studio.
Model Configuration
Setting Default Model
1. Environment Variable (Recommended):
2. Settings File:
3. Project Settings:
Configuration Precedence
Settings 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
Available Models
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
Features Implementation
File Analysis with @ Syntax
The MCP server passes file references directly to Gemini CLI:
Supported patterns:
@file.js- Single file@src/*.ts- Glob pattern@.- Current directory
Sandbox Mode
When sandbox: true is passed to ask-gemini:
Enables safe code execution in isolated environment.
YOLO Mode
When yolo: true is passed:
Auto-approves ALL tool executions without confirmation prompts. Required for any Gemini CLI extension that needs tool approval.
Gemini CLI Extensions
Gemini CLI supports extensions that add new capabilities. Extensions may require yolo: true to auto-approve their tool calls.
Installing Extensions:
Popular Extensions:
Google Workspace
Gmail, Drive, Sheets, Docs, Calendar, Chat
https://github.com/gemini-cli-extensions/workspace
Usage with MCP:
⚠️ Security Note: Without
yolo: 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).
Change Mode
When changeMode: true is passed:
Returns structured edits in **FILE: path:line** format with OLD/NEW blocks.
Web Search Grounding
The search tool uses Gemini's built-in Google Search grounding:
Returns real-time information with source attribution.
Multimodal Analysis
The analyze-media tool handles various file types:
Supports images, PDFs, and other media formats.
Error Handling
Model Fallback
When quota is exceeded on gemini-3-pro-preview:
Server detects quota error
Automatically retries with
gemini-3-flash-previewReturns result with fallback notification
Timeout Handling
For long-running operations:
Server sends progress notifications
Keeps connection alive during processing
Returns result when complete
Troubleshooting
"Command not found: gemini"
"Not authenticated"
"Quota exceeded"
Wait for quota reset (typically 1 minute)
Or use
gemini-3-flash-previewmodelOr upgrade to paid API tier
"File not found" with @ syntax
Use absolute paths when possible
Verify file exists:
ls -la path/to/fileCheck working directory
CLI Flags Reference
-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)
Links
Last updated
Was this helpful?