Skip to main content
Glama
LNS2905

Gemini Chat MCP

README.md
# Gemini Chat MCP

A simple MCP server for chatting with Google Gemini and custom Gems.

## Features

- **Chat with Gemini** - Send messages and receive responses (text + images)
- **Custom Gems support** - Chat with your custom Gems by providing gem_id
- **Model selection** - Choose between Gemini 3 Pro (default) or Gemini 2.5 Flash
- **Auto cookie sync** - Chrome extension automatically syncs cookies

## Installation

```bash
cd C:/Working/gemini-chat-mcp
pip install -e .
```

## Configuration

### Option 1: Chrome Extension (Recommended)

1. Open Chrome and go to `chrome://extensions/`
2. Enable "Developer mode"
3. Click "Load unpacked" and select the `chrome-extension` folder
4. Login to [gemini.google.com](https://gemini.google.com)
5. Click the extension icon to verify cookies are synced

The extension runs a local server on port 52525 that the MCP server uses to fetch cookies automatically.

### Option 2: Manual .env

Copy `.env.example` to `.env` and fill in your cookies:

```
GEMINI_SECURE_1PSID=your_psid_here
GEMINI_SECURE_1PSIDTS=your_psidts_here
```

To get cookies manually:
1. Login to [gemini.google.com](https://gemini.google.com)
2. Open DevTools (F12) → Application → Cookies
3. Copy `__Secure-1PSID` and `__Secure-1PSIDTS` values

## Usage with Amp

Add to your settings.json:

```json
{
  "amp.mcpServers": {
    "gemini-chat": {
      "command": "python",
      "args": ["C:/Working/gemini-chat-mcp/src/gemini_chat_mcp/server.py"]
    }
  }
}
```

Or using module:

```json
{
  "amp.mcpServers": {
    "gemini-chat": {
      "command": "python",
      "args": ["-m", "gemini_chat_mcp"],
      "cwd": "C:/Working/gemini-chat-mcp"
    }
  }
}
```

## Tools

### chat

Chat with Gemini. Can generate text and images.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `message` | string | ✅ | Message to send to Gemini |
| `gem_id` | string | ❌ | Custom Gem ID from URL |
| `model` | string | ❌ | `gemini-3-pro` (default) or `gemini-2.5-flash` |

**Example - Basic chat:**
```json
{"message": "Hello, how are you?"}
```

**Example - Chat with custom Gem:**
```json
{
  "message": "Hello!",
  "gem_id": "10wwoIn-UvdTVzg4rFH3szi4wk8oTo8Cf"
}
```

**Example - Use specific model:**
```json
{
  "message": "Explain quantum computing",
  "model": "gemini-2.5-flash"
}
```

### set_cookie

Update cookies when they expire.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `psidts` | string | ✅ | New `__Secure-1PSIDTS` value (starts with `sidts-`) |
| `psid` | string | ❌ | New `__Secure-1PSID` value (starts with `g.a`) |

## How to get Gem ID

From a Gem URL like:
```
https://gemini.google.com/gem/10wwoIn-UvdTVzg4rFH3szi4wk8oTo8Cf
```

The Gem ID is: `10wwoIn-UvdTVzg4rFH3szi4wk8oTo8Cf`

## Project Structure

```
gemini-chat-mcp/
├── src/gemini_chat_mcp/
│   ├── __init__.py
│   ├── __main__.py
│   └── server.py          # Main MCP server
├── chrome-extension/       # Cookie sync extension
│   ├── manifest.json
│   ├── background.js
│   ├── popup.html
│   ├── popup.js
│   └── icons/
├── .env.example
├── .gitignore
├── pyproject.toml
└── README.md
```

## License

MIT