Gemini MCP Bridge
by mn3-99
README.md
# Gemini MCP Bridge
A Model Context Protocol (MCP) server that bridges to Gemini's web chat interface, providing real-time streaming of both the thinking process and responses. Features advanced stealth capabilities, proxy rotation, fingerprint evasion, and session persistence.
## Features
- **Real-time Streaming**: Capture Gemini's thinking process and response tokens as they generate
- **Stealth Browser**: Advanced fingerprint evasion using Playwright with stealth plugins
- **Proxy Rotation**: Automatic proxy health checks and rotation with multiple source support
- **Session Persistence**: Cookies, localStorage, and sessionStorage saved/restored across runs
- **Fingerprint Randomization**: Canvas, WebGL, audio, fonts, and navigator spoofing
- **MCP Protocol**: Full MCP server with tools, resources, and prompts
- **No API Key Required**: Uses web interface automation (respects ToS)
## Installation
```bash
cd /content/gemini_mcp
pip install -e ".[dev]"
playwright install chromium
```
## Configuration
Edit `config/settings.yaml` to customize:
- Browser settings (headless, stealth, args)
- Fingerprint randomization
- Proxy sources and rotation
- Gemini selectors and timeouts
- Session persistence
- MCP server settings
## Usage
### As MCP Server (stdio)
```bash
# Run directly
python -m gemini_mcp
# Or use the entry point
./gemini-mcp
```
### With Claude Desktop
Add to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"gemini-bridge": {
"command": "python",
"args": ["-m", "gemini_mcp"],
"cwd": "/content/gemini_mcp"
}
}
}
```
### Available Tools
| Tool | Description |
|------|-------------|
| `gemini_send_message` | Send message, stream thinking + response |
| `gemini_stream_thinking` | Stream only thinking process |
| `gemini_get_history` | Get conversation history |
| `gemini_new_chat` | Start new conversation |
| `gemini_get_status` | Check connection status |
| `gemini_rotate_proxy` | Rotate to new proxy |
### Available Resources
| URI | Description |
|-----|-------------|
| `gemini://session/state` | Current session state |
| `gemini://conversation/history` | Full conversation history |
| `gemini://conversation/current` | Currently streaming message |
| `gemini://config/current` | Active configuration |
### Available Prompts
| Prompt | Description |
|--------|-------------|
| `gemini_chat` | General chat with topic/persona |
| `gemini_analyze` | Content analysis |
| `gemini_code` | Code generation/review |
## Architecture
```
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ MCP Client │────▶│ MCP Server │────▶│ Browser Manager│
│ (Claude, etc.) │ │ (gemini_mcp) │ │ (Playwright) │
└─────────────────┘ └──────────────────┘ └────────┬────────┘
│
┌─────────────────────────────────┘
▼
┌──────────────────┐ ┌──────────────────┐
│ Stealth Layer │ │ Proxy Manager │
│ (Fingerprint, │ │ (Rotation, │
│ WebGL, Canvas, │ │ Health Check) │
│ Audio, Fonts) │ └──────────────────┘
└──────────────────┘
│
▼
┌──────────────────┐
│ Gemini Chat │
│ Controller │
│ (Streaming, │
│ Thinking, │
│ Recovery) │
└──────────────────┘
```
## Proxy Configuration
Add proxies to `proxies.txt`:
```
http://user:pass@host:port
socks5://host:port
host:port
```
Or configure API sources in `config/settings.yaml`:
```yaml
proxy:
sources:
- type: "api"
url: "https://your-proxy-api.com/getproxies"
```
## Session Persistence
Sessions are saved to `./session/`:
- `cookies.json` - Browser cookies
- `local_storage.json` - localStorage data
- `state.json` - Full session state
## Logging
Logs written to `./logs/gemini_mcp.log` with rotation.
## Troubleshooting
### Chat not loading
- Check selectors in `config/settings.yaml` match current Gemini UI
- Increase timeouts if on slow connection
- Try disabling headless mode to debug
### Proxy issues
- Verify proxies in `proxies.txt` are working
- Check proxy authentication format
- Disable proxy in config if not needed
### Detection issues
- Enable all stealth features in config
- Use residential proxies for better results
- Rotate user agents and fingerprints
## Legal Notice
This tool automates a web interface. Use responsibly and in accordance with Google's Terms of Service. The authors are not responsible for any misuse.
## License
MIT LicenseThis server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues