gemini-webapi-mcp
MCP server for Google Gemini that enables image generation, editing, file analysis, and chat using browser cookies, no API key needed.
README
<h1 align="center">gemini-webapi-mcp</h1>
<p align="center"> MCP-сервер для Google Gemini — генерация и редактирование изображений, чат и анализ файлов через браузерные cookies.<br> Без API-ключей. Бесплатно. </p>
<p align="center"> <a href="https://github.com/AndyShaman/gemini-webapi-mcp/blob/main/LICENSE"><img src="https://img.shields.io/github/license/AndyShaman/gemini-webapi-mcp?style=flat-square&color=green" alt="License"></a> <img src="https://img.shields.io/badge/python-3.10+-blue?style=flat-square&logo=python&logoColor=white" alt="Python"> <img src="https://img.shields.io/badge/MCP-compatible-8A2BE2?style=flat-square" alt="MCP"> <a href="https://github.com/AndyShaman/gemini-webapi-mcp/stargazers"><img src="https://img.shields.io/github/stars/AndyShaman/gemini-webapi-mcp?style=flat-square&color=yellow" alt="Stars"></a> </p>
<p align="center"> <a href="https://t.me/AI_Handler"><img src="https://img.shields.io/badge/Telegram-канал автора-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram"></a> <a href="https://www.youtube.com/channel/UCLkP6wuW_P2hnagdaZMBtCw"><img src="https://img.shields.io/badge/YouTube-канал автора-FF0000?style=for-the-badge&logo=youtube&logoColor=white" alt="YouTube"></a> </p>
Возможности
- Генерация изображений по текстовому описанию (Nano Banana 2 с поддержкой пропорций)
- 2x разрешение — автоматически скачивает upscaled-версию (2048x2048 → 2816x1536 и выше)
- Редактирование изображений — отправьте картинку + промпт и получите изменённую версию
- Анализ файлов — видео, изображения, PDF, документы
- Текстовый чат с Gemini (Flash, Pro, Flash-Thinking)
- Авто-удаление вотермарки — sparkle-метка Gemini убирается через gwt-mini от @allenk (поддержка профилей Gemini 3.5 и legacy, macOS / Windows / Linux)
- Авто-аутентификация через cookies из Chrome
Быстрый старт
1. Войдите в Gemini
Откройте Chrome, перейдите на gemini.google.com и войдите в свой Google-аккаунт.
2. Установите MCP-сервер
Из GitHub (без клонирования):
uv run --with "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git" gemini-webapi-mcp
Локальная установка:
git clone https://github.com/AndyShaman/gemini-webapi-mcp.git
cd gemini-webapi-mcp
uv sync
python scripts/install_gwt.py # опционально: удаление вотермарки (см. ниже)
uv run gemini-webapi-mcp
3. Добавьте MCP-конфиг
<details> <summary><b>Claude Code</b></summary>
claude mcp add-json gemini '{"command":"uv","args":["run","--with","gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git","gemini-webapi-mcp"]}'
Или добавьте вручную в .mcp.json в корне проекта:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
</details>
<details> <summary><b>Claude Desktop</b></summary>
Добавьте в конфиг Claude Desktop:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
</details>
<details> <summary><b>Другие MCP-клиенты</b></summary>
Используйте стандартный MCP stdio-конфиг:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
Путь к файлу конфига зависит от вашего MCP-клиента.
</details> Локальная установка (после клонирования) — замените args на:
"args": ["--directory", "/path/to/gemini-webapi-mcp", "run", "gemini-webapi-mcp"]
4. Установите скилл для Claude Code (опционально)
Папка skill/ содержит скилл для Claude Code — подсказки по промптингу, документацию по тулам и гайд по генерации изображений. Скилл автоматически активируется при работе с Gemini.
cp -r skill ~/.claude/skills/gemini-mcp
5. Проверьте
Запустите сервер вручную — если инициализация прошла без ошибок, всё работает:
uv run --with "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git" gemini-webapi-mcp
После этого откройте Claude Code или Claude Desktop и попробуйте: «Сгенерируй картинку кота в акварельном стиле через Gemini».
Аутентификация
Сервер автоматически читает cookies из Chrome через browser-cookie3.
Несколько Google-аккаунтов? Установите
GEMINI_ACCOUNT_INDEX— номер аккаунта из Chrome (0 = первый, 1 = второй, ...). Посмотрите порядок: кликните на аватарку в gemini.google.com.
Если автоопределение cookies не работает, задайте их вручную:
- Откройте Chrome DevTools на gemini.google.com → Application → Cookies
- Скопируйте значения
__Secure-1PSIDи__Secure-1PSIDTS - Добавьте в MCP-конфиг:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"],
"env": {
"GEMINI_PSID": "your__Secure-1PSID_value",
"GEMINI_PSIDTS": "your__Secure-1PSIDTS_value"
}
}
}
}
Переменные окружения
| Переменная | Описание | По умолчанию |
|---|---|---|
GEMINI_PSID |
Значение cookie __Secure-1PSID |
авто из Chrome |
GEMINI_PSIDTS |
Значение cookie __Secure-1PSIDTS |
авто из Chrome |
GEMINI_LANGUAGE |
Язык ответов Gemini (ru, en, ja, ...) |
en |
GEMINI_ACCOUNT_INDEX |
Индекс Google-аккаунта (0, 1, 2, ...) | 0 |
Высокое разрешение (2x)
Сервер автоматически запрашивает у Google увеличенную версию сгенерированного изображения — тот же механизм, что использует кнопка "Download" в веб-интерфейсе Gemini. Google выполняет server-side upscale, и вы получаете изображение в 2x разрешении:
| Модель | Нативное | 2x (скачивается) |
|---|---|---|
| Flash-Thinking (16:9) | 1408x768 | 2816x1536 |
| Flash-Thinking (9:16) | 768x1376 | 1536x2752 |
| Flash-Thinking (1:1) | 1024x1024 | 2048x2048 |
Если 2x-версия недоступна (таймаут, ошибка сети), сервер автоматически использует нативное разрешение.
Удаление вотермарки
Gemini добавляет sparkle-метку (четырёхконечную звёздочку) в правый нижний угол сгенерированных изображений. Сервер вызывает CLI-утилиту gwt-mini от @allenk — она реализует Reverse Alpha Blending с поддержкой профилей Gemini 3.5 и legacy и работает в офлайне, без ML-моделей.
Установка одной командой из корня клонированного репозитория (macOS, Linux, Windows):
python scripts/install_gwt.py
Скрипт скачивает бинарник gwt-mini из релизов allenk/GeminiWatermarkTool, проверяет SHA-256 и кладёт в tools/gwt/. Бинарник не коммитится в репозиторий. Без него сервер продолжает работать — просто оставляет вотермарку на месте и пишет предупреждение в лог. Чтобы временно отключить удаление, задайте GEMINI_WM_KEEP=1.
Инструменты
| Инструмент | Описание |
|---|---|
gemini_generate_image |
Генерация новых или редактирование существующих изображений |
gemini_upload_file |
Анализ файлов — видео, изображения, PDF, документы |
gemini_analyze_url |
Анализ URL — YouTube-видео, веб-страницы, статьи |
gemini_chat |
Текстовый чат (одиночный или multi-turn) |
gemini_start_chat |
Начать multi-turn сессию |
gemini_reset |
Переинициализация клиента при ошибках авторизации |
Модели
| Модель | По умолчанию для | Примечание |
|---|---|---|
gemini-3.0-flash |
чат, анализ файлов | Быстрая |
gemini-3.0-flash-thinking |
генерация изображений | Nano Banana 2, поддержка пропорций |
gemini-3.0-pro |
— | Альтернативная модель |
Примеры использования
После настройки MCP-конфига Claude сам вызывает нужные инструменты. Просто попросите в чате:
| Задача | Что написать Claude |
|---|---|
| Сгенерировать изображение | «Сгенерируй через Gemini кота в акварельном стиле» |
| Отредактировать изображение | «Отредактируй через Gemini /path/to/cat.png — сделай кота серым» |
| Итеративная правка | «Теперь сделай фон темнее» (в том же разговоре) |
| Проанализировать видео | «Проанализируй через Gemini это видео: https://youtube.com/watch?v=...» |
| Проанализировать файл | «Загрузи в Gemini /path/to/doc.pdf и сделай краткое резюме» |
Инструменты, которые Claude вызовет:
gemini_generate_image(prompt="кот в акварельном стиле")
gemini_generate_image(prompt="сделай кота серым", files=["/path/to/cat.png"])
gemini_generate_image(prompt="сделай фон темнее", conversation_id=["c_abc", "r_123", "rc_456"])
gemini_analyze_url(url="https://youtube.com/watch?v=...", prompt="О чём это видео?")
gemini_upload_file(file_path="/path/to/doc.pdf", prompt="Сделай краткое резюме")
Благодарности
Этот проект построен на основе библиотеки gemini-webapi от @HanaokaYuzu (форк @xob0t с поддержкой curl_cffi) — реверс-инжиниринговой асинхронной Python-обёртки для веб-приложения Google Gemini. Лицензия: AGPL-3.0.
Удаление вотермарки выполняется бинарником gwt-mini от @allenk (Allen Kuo, MIT License) — он реализует алгоритм Reverse Alpha Blending и держит откалиброванные профили под текущий и legacy формат метки. Калибровочные alpha-карты для legacy-профиля изначально пришли из gemini-watermark-remover от @GargantuaX (MIT License). Бинарник скачивается локально скриптом scripts/install_gwt.py и не входит в этот репозиторий.
Лицензия
AGPL-3.0 — свободно используйте, модифицируйте и распространяйте при условии сохранения открытости исходного кода.
@AndyShaman · gemini-webapi-mcp
<h1 align="center">gemini-webapi-mcp</h1>
<p align="center"> MCP server for Google Gemini — image generation/editing, chat and file analysis via browser cookies.<br> No API keys. Free. </p>
<p align="center"> <a href="https://github.com/AndyShaman/gemini-webapi-mcp/blob/main/LICENSE"><img src="https://img.shields.io/github/license/AndyShaman/gemini-webapi-mcp?style=flat-square&color=green" alt="License"></a> <img src="https://img.shields.io/badge/python-3.10+-blue?style=flat-square&logo=python&logoColor=white" alt="Python"> <img src="https://img.shields.io/badge/MCP-compatible-8A2BE2?style=flat-square" alt="MCP"> <a href="https://github.com/AndyShaman/gemini-webapi-mcp/stargazers"><img src="https://img.shields.io/github/stars/AndyShaman/gemini-webapi-mcp?style=flat-square&color=yellow" alt="Stars"></a> </p>
<p align="center"> <a href="https://t.me/AI_Handler"><img src="https://img.shields.io/badge/Telegram-Author's_Channel-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram"></a> <a href="https://www.youtube.com/channel/UCLkP6wuW_P2hnagdaZMBtCw"><img src="https://img.shields.io/badge/YouTube-Author's_Channel-FF0000?style=for-the-badge&logo=youtube&logoColor=white" alt="YouTube"></a> </p>
Features
- Image generation from text descriptions (Nano Banana 2 with aspect ratio support)
- 2x resolution — automatically downloads upscaled version (2048x2048 → 2816x1536 and above)
- Image editing — send an image + prompt to get a modified version
- File analysis — video, images, PDF, documents
- Text chat with Gemini (Flash, Pro, Flash-Thinking)
- Auto watermark removal — Gemini's sparkle mark is stripped via gwt-mini by @allenk (Gemini 3.5 + legacy profiles, macOS / Windows / Linux)
- Auto-authentication via Chrome browser cookies
Quick Start
1. Log into Gemini
Open Chrome, go to gemini.google.com and sign in.
2. Install the MCP server
From GitHub (no clone needed):
uv run --with "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git" gemini-webapi-mcp
Local install:
git clone https://github.com/AndyShaman/gemini-webapi-mcp.git
cd gemini-webapi-mcp
uv sync
python scripts/install_gwt.py # optional: watermark removal (see below)
uv run gemini-webapi-mcp
3. Add MCP config
<details> <summary><b>Claude Code</b></summary>
claude mcp add-json gemini '{"command":"uv","args":["run","--with","gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git","gemini-webapi-mcp"]}'
Or add manually to .mcp.json in your project root:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
</details>
<details> <summary><b>Claude Desktop</b></summary>
Add to Claude Desktop config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
</details>
<details> <summary><b>Other MCP clients</b></summary>
Use the standard MCP stdio config:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
Config file path depends on your MCP client.
</details> Local install (after cloning) — replace args with:
"args": ["--directory", "/path/to/gemini-webapi-mcp", "run", "gemini-webapi-mcp"]
4. Install the skill for Claude Code (optional)
The skill/ folder contains a Claude Code skill — prompting tips, tool documentation and an image generation guide. The skill auto-activates when working with Gemini.
cp -r skill ~/.claude/skills/gemini-mcp
5. Verify
Run the server manually — if it initializes without errors, everything works:
uv run --with "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git" gemini-webapi-mcp
Then open Claude Code or Claude Desktop and try: "Generate a watercolor cat image with Gemini".
Authentication
The server reads cookies from Chrome automatically via browser-cookie3.
Multiple Google accounts? Set
GEMINI_ACCOUNT_INDEX— the account number from Chrome (0 = first, 1 = second, ...). Check the order by clicking your avatar on gemini.google.com.
If cookie auto-detection fails, set them manually:
- Open Chrome DevTools on gemini.google.com → Application → Cookies
- Copy
__Secure-1PSIDand__Secure-1PSIDTSvalues - Add to your MCP config:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"],
"env": {
"GEMINI_PSID": "your__Secure-1PSID_value",
"GEMINI_PSIDTS": "your__Secure-1PSIDTS_value"
}
}
}
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
GEMINI_PSID |
Cookie value __Secure-1PSID |
auto from Chrome |
GEMINI_PSIDTS |
Cookie value __Secure-1PSIDTS |
auto from Chrome |
GEMINI_LANGUAGE |
Gemini response language (ru, en, ja, ...) |
en |
GEMINI_ACCOUNT_INDEX |
Google account index (0, 1, 2, ...) | 0 |
High Resolution (2x)
The server automatically requests an upscaled version of each generated image — the same mechanism used by the "Download" button in Gemini's web interface. Google performs server-side upscaling, delivering images at 2x resolution:
| Model | Native | 2x (downloaded) |
|---|---|---|
| Flash-Thinking (16:9) | 1408x768 | 2816x1536 |
| Flash-Thinking (9:16) | 768x1376 | 1536x2752 |
| Flash-Thinking (1:1) | 1024x1024 | 2048x2048 |
If the 2x version is unavailable (timeout, network error), the server automatically falls back to native resolution.
Watermark Removal
Gemini adds a sparkle watermark (4-point star) to the bottom-right corner of generated images. The server shells out to gwt-mini by @allenk — it implements Reverse Alpha Blending with calibrated profiles for both current Gemini 3.5 and the legacy mark, runs offline, no ML models.
Install with one command from a cloned checkout (macOS, Linux, Windows):
python scripts/install_gwt.py
The script downloads the gwt-mini binary from allenk/GeminiWatermarkTool releases, verifies the SHA-256, and places it under tools/gwt/. The binary is not committed. Without it the server keeps working — it just leaves the watermark in place and logs a warning. Set GEMINI_WM_KEEP=1 to disable removal even when the binary is installed.
Tools
| Tool | Description |
|---|---|
gemini_generate_image |
Generate new or edit existing images |
gemini_upload_file |
Analyze files — video, images, PDF, documents |
gemini_analyze_url |
Analyze URLs — YouTube videos, webpages, articles |
gemini_chat |
Text chat (single or multi-turn) |
gemini_start_chat |
Start a multi-turn session |
gemini_reset |
Re-initialize client on auth errors |
Models
| Model | Default for | Notes |
|---|---|---|
gemini-3.0-flash |
chat, file analysis | Fast |
gemini-3.0-flash-thinking |
image generation | Nano Banana 2, supports aspect ratios |
gemini-3.0-pro |
— | Alternative model |
Usage Examples
Once configured, Claude calls the right tools automatically. Just ask in chat:
| Task | What to tell Claude |
|---|---|
| Generate an image | "Generate a watercolor cat with Gemini" |
| Edit an image | "Edit /path/to/cat.png with Gemini — make the cat gray" |
| Iterative refinement | "Now make the background darker" (same conversation) |
| Analyze a video | "Analyze this video with Gemini: https://youtube.com/watch?v=..." |
| Analyze a file | "Upload /path/to/doc.pdf to Gemini and summarize it" |
Tools that Claude will call:
gemini_generate_image(prompt="a cat in watercolor style")
gemini_generate_image(prompt="make it gray", files=["/path/to/cat.png"])
gemini_generate_image(prompt="make the background darker", conversation_id=["c_abc", "r_123", "rc_456"])
gemini_analyze_url(url="https://youtube.com/watch?v=...", prompt="Summarize this video")
gemini_upload_file(file_path="/path/to/doc.pdf", prompt="Summarize key points")
Acknowledgements
This project is built on top of gemini-webapi by @HanaokaYuzu (fork by @xob0t with curl_cffi support) — a reverse-engineered async Python wrapper for the Google Gemini web app. Licensed under AGPL-3.0.
Watermark removal is performed by the gwt-mini binary by @allenk (Allen Kuo, MIT License) — it implements Reverse Alpha Blending and ships calibrated profiles for both the current and legacy Gemini sparkle. Legacy-profile alpha maps originally came from gemini-watermark-remover by @GargantuaX (MIT License). The binary is fetched locally by scripts/install_gwt.py and is not redistributed with this repository.
License
AGPL-3.0 — free to use, modify, and distribute, provided the source code remains open.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。