Skip to main content
Glama
Gemini MCP Server

Gemini MCP Server

by taehun-kmu
README.md
# Gemini MCP Server

MCP (Model Context Protocol) Server with Google Gemini CLI integration for AI second opinions and validation in development workflows.

## Features

- šŸ¤– **AI Second Opinions**: Get alternative perspectives from Google's Gemini AI
- šŸ” **Automatic Uncertainty Detection**: Triggers consultations when uncertainty is detected
- ⚔ **Rate Limiting**: Built-in rate limiting to prevent API abuse
- šŸ›”ļø **Configurable Models**: Support for different Gemini models
- šŸ“Š **Consultation Logging**: Track all AI consultations with timestamps

## Quick Start

### Using uvx (Recommended)

Run directly without installation:

```bash
# Run in current directory
uvx gemini-mcp-server

# Run with specific project root
uvx gemini-mcp-server --project-root /path/to/project
```

### Local Development

```bash
# Clone the repository
git clone https://github.com/taehun-kmu/gemini-mcp-server
cd gemini-mcp-server

# Install with uv
uv pip install -e .

# Run the server
gemini-mcp-server
```

## Prerequisites

1. **Node.js 18+** - Required for Gemini CLI
2. **Python 3.8+** - Required for MCP server
3. **Gemini CLI** - Install and authenticate:

```bash
# Install Gemini CLI
npm install -g @google/gemini-cli

# Authenticate (run once)
gemini
```

## Configuration

Create a `gemini-config.json` file in your project root:

```json
{
  "enabled": true,
  "auto_consult": true,
  "cli_command": "gemini",
  "timeout": 60,
  "rate_limit_delay": 2.0,
  "model": "gemini-2.5-flash",
  "log_consultations": true
}
```

### Environment Variables

Override configuration with environment variables:

- `GEMINI_ENABLED`: Enable/disable integration
- `GEMINI_AUTO_CONSULT`: Enable/disable automatic consultation
- `GEMINI_CLI_COMMAND`: CLI command (default: "gemini")
- `GEMINI_TIMEOUT`: Command timeout in seconds
- `GEMINI_RATE_LIMIT`: Delay between consultations
- `GEMINI_MODEL`: Model to use (default: "gemini-2.5-flash")

## MCP Tools

The server exposes three MCP tools:

1. **consult_gemini**: Get second opinions from Gemini
   - `query`: The question or topic
   - `context`: Additional context
   - `comparison_mode`: Request structured comparison format

2. **gemini_status**: Check integration status and statistics

3. **toggle_gemini_auto_consult**: Enable/disable automatic consultation
   - `enable`: true/false or omit to toggle

## Claude Code Integration

Configure Claude Code to use this MCP server by adding to your MCP configuration:

```json
{
  "mcpServers": {
    "gemini": {
      "command": "uvx",
      "args": ["gemini-mcp-server"],
      "env": {
        "GEMINI_ENABLED": "true"
      }
    }
  }
}
```

Note: Add `"--project-root", "/path/to/project"` to args if you need to specify a different project directory.

## Development

### Project Structure

```
gemini-mcp-server/
ā”œā”€ā”€ gemini_mcp/
│   ā”œā”€ā”€ __init__.py
│   ā”œā”€ā”€ __main__.py         # CLI entry point
│   ā”œā”€ā”€ gemini_integration.py  # Gemini integration logic
│   └── server.py           # MCP server implementation
ā”œā”€ā”€ pyproject.toml          # Package configuration
ā”œā”€ā”€ README.md              # This file
ā”œā”€ā”€ LICENSE                # MIT License
ā”œā”€ā”€ setup-gemini-integration.sh  # Setup script
└── gemini-config.json     # Example configuration
```

### Running Tests

```bash
# Install dev dependencies
uv pip install -e ".[dev]"

# Run tests
pytest

# Format code
ruff format gemini_mcp
ruff check gemini_mcp
```

## License

MIT License - see LICENSE file for details.