@yusukedev/gemini-cli-mcp
Version:
A secure Model Context Protocol server for Gemini CLI with automatic fallback, extended timeout (180s), and model transparency features
142 lines (102 loc) β’ 3.78 kB
Markdown
# Gemini CLI MCP Server
A secure Model Context Protocol (MCP) server that provides access to Google's Gemini CLI functionality through standardized MCP tools.
## β¨ Features
- π¬ **Chat Integration**: Direct conversation with Gemini models for development consultation and code assistance
- π **Automatic Fallback**: Seamlessly switches from Gemini 2.5 Pro to Flash when quota limits are reached
- π‘οΈ **Secure Implementation**: Uses temporary files to prevent shell injection vulnerabilities
- β‘ **Extended Timeout**: 180-second timeout for processing complex queries
- π **Easy Integration**: Simple setup with Claude Desktop and other MCP-compatible clients
- π **Model Transparency**: Response includes information about which model was used (Pro or Flash)
## π§ Prerequisites
1. **Node.js 18+** is required
2. **Gemini CLI** must be installed and authenticated:
```bash
npm install -g @google/generative-ai-cli
gemini auth
```
### Installation
Install globally via npm:
```bash
npm install -g @yusukedev/gemini-cli-mcp
```
Or use directly with npx:
```bash
npx @yusukedev/gemini-cli-mcp
```
### Configuration
Add to your Claude Desktop `claude_desktop_config.json` file (or similar MCP client configuration):
```json
{
"mcpServers": {
"gemini-cli": {
"command": "npx",
"args": ["@yusukedev/gemini-cli-mcp"]
}
}
}
```
Or if installed globally:
```json
{
"mcpServers": {
"gemini-cli": {
"command": "gemini-cli-mcp"
}
}
}
```
## π οΈ Available Tools
### `gemini_chat_pro`
Chat with Gemini 2.5 Pro for development consultation and code assistance.
If this tool failsοΌquota exceeded, etc.οΌ, use `gemini_chat_flash` as a fallback.
**Parameters:**
- `message` (required): The message or question to send to Gemini
- `context` (optional): Additional context or code to include in the conversation
**Example:**
```javascript
{
"name": "gemini_chat_pro",
"arguments": {
"message": "Review this TypeScript code for potential improvements",
"context": "function validateEmail(email: string): boolean { return /\\S+@\\S+\\.\\S+/.test(email); }"
}
}
```
### `gemini_chat_flash`
Chat with Gemini 2.5 Flash for development consultation and code assistance.
Use this if `gemini_chat_pro` fails.
**Parameters:**
- `message` (required): The message or question to send to Gemini
- `context` (optional): Additional context or code to include in the conversation
**Example:**
```javascript
{
"name": "gemini_chat_flash",
"arguments": {
"message": "Review this TypeScript code for potential improvements",
"context": "function validateEmail(email: string): boolean { return /\\S+@\\S+\\.\\S+/.test(email); }"
}
}
```
## π Automatic Fallback
The server automatically handles quota limits by:
1. **Primary**: Attempts to use `gemini-2.5-pro` (high quality)
2. **Fallback**: Switches to `gemini-2.5-flash` if Pro quota is exceeded
3. **Transparency**: Response includes model information and fallback status
## π System Requirements
- **Node.js**: 18.0.0 or higher
- **OS**: Windows, macOS, Linux (with WSL)
- **Gemini CLI**: [Google AI Studio](https://ai.google.dev/)
## π Debugging
Since MCP servers operate over stdio, debugging can be challenging. We recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector), which is available as a package script:
```bash
npm run inspector
```
## π License
MIT License
## π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## π Links
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [Google AI Studio](https://ai.google.dev/)
- [Gemini CLI Documentation](https://www.npmjs.com/package/@google/generative-ai-cli)