gemini-webapi-mcp
MCP-сервер для Google Gemini — генерация и редактирование изображений, чат и анализ файлов через браузерные cookies.
Без API-ключей. Бесплатно.
Возможности
- Генерация изображений по текстовому описанию (модель Pro с поддержкой пропорций)
- 2x разрешение — автоматически скачивает upscaled-версию (2816x1536 вместо 1408x768)
- Редактирование изображений — отправьте картинку + промпт и получите изменённую версию
- Анализ файлов — видео, изображения, PDF, документы
- Текстовый чат с Gemini (Flash, Pro, Flash-Thinking)
- Авто-удаление вотермарки — нейросеть LaMa убирает sparkle-метку Gemini локально
- Авто-аутентификация через cookies из Chrome
Быстрый старт
1. Войдите в Gemini
Откройте Chrome, перейдите на gemini.google.com и войдите в свой Google-аккаунт.
2. Установите MCP-сервер
Из GitHub (без клонирования):
uv run --with "gemini-webapi-mcp[watermark] @ 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
uv run gemini-webapi-mcp
3. Добавьте MCP-конфиг
Добавьте в ~/.config/mcp/mcp_servers.json:
Из GitHub:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp[watermark] @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
Без удаления вотермарки: замените
gemini-webapi-mcp[watermark]наgemini-webapi-mcp.
Локально (после клонирования):
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "/path/to/gemini-webapi-mcp", "gemini-webapi-mcp"]
}
}
}
4. Установите скилл для Claude Code (опционально)
Папка skill/ содержит скилл для Claude Code — подсказки по промптингу, документацию по тулам и гайд по генерации изображений. Скилл автоматически активируется при работе с Gemini.
cp -r skill ~/.claude/skills/gemini-mcp
5. Проверьте
mcp-cli call gemini gemini_chat '{"prompt": "Привет!"}'
Если получили ответ — всё работает.
Аутентификация
Сервер автоматически читает cookies из Chrome через browser-cookie3.
Несколько Google-аккаунтов? При авто-определении выбор аккаунта непредсказуем. Используйте env vars
GEMINI_PSID/GEMINI_PSIDTSчтобы явно указать нужный аккаунт.
Если автоопределение не работает или у вас несколько аккаунтов, задайте cookies вручную:
- Откройте Chrome DevTools на gemini.google.com → Application → Cookies
- Скопируйте значения
__Secure-1PSIDи__Secure-1PSIDTS - Добавьте в MCP-конфиг:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp[watermark] @ 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 |
Высокое разрешение (2x)
Сервер автоматически запрашивает у Google увеличенную версию сгенерированного изображения — тот же механизм, что использует кнопка "Download" в веб-интерфейсе Gemini. Google выполняет server-side upscale, и вы получаете изображение в 2x разрешении:
| Модель | Нативное | 2x (скачивается) |
|---|---|---|
| Pro (16:9) | 1408x768 | 2816x1536 |
| Pro (9:16) | 768x1408 | 1536x2816 |
| Pro (1:1) | 1024x1024 | 2048x2048 |
| Flash | 1024x1024 | 2048x2048 |
Если 2x-версия недоступна (таймаут, ошибка сети), сервер автоматически использует нативное разрешение.
Удаление вотермарки
Gemini добавляет sparkle-метку (четырёхконечную звёздочку) в правый нижний угол сгенерированных изображений. Сервер автоматически удаляет её с помощью нейросети LaMa.
Установка:
# Из GitHub — с поддержкой удаления вотермарки
uv run --with "gemini-webapi-mcp[watermark] @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git" gemini-webapi-mcp
# Или отдельно, если уже установлен
pip install onnxruntime
При первом запуске модель LaMa (208 МБ) автоматически скачивается и кэшируется в ~/.cache/gemini-mcp/. Если onnxruntime не установлен — сервер работает нормально, просто не удаляет вотермарку.
Инструменты
| Инструмент | Описание |
|---|---|
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-pro | генерация изображений | Поддержка пропорций |
gemini-3.0-flash-thinking | — | Показывает процесс рассуждения |
Примеры использования
Сгенерировать изображение:
mcp-cli call gemini gemini_generate_image '{"prompt": "кот в акварельном стиле"}'
Отредактировать изображение:
mcp-cli call gemini gemini_generate_image '{"prompt": "сделай кота серым", "files": ["/path/to/cat.png"]}'
Проанализировать YouTube-видео или URL:
mcp-cli call gemini gemini_analyze_url '{"url": "https://youtube.com/watch?v=...", "prompt": "О чём это видео?"}'
Проанализировать файл:
mcp-cli call gemini gemini_upload_file '{"file_path": "/path/to/video.mp4", "prompt": "О чём это видео?"}'
Благодарности
Этот проект построен на основе библиотеки gemini-webapi от @HanaokaYuzu — реверс-инжиниринговой асинхронной Python-обёртки для веб-приложения Google Gemini. Лицензия: AGPL-3.0.
Лицензия
AGPL-3.0 — свободно используйте, модифицируйте и распространяйте при условии сохранения открытости исходного кода.
@AndyShaman · gemini-webapi-mcp
gemini-webapi-mcp
MCP server for Google Gemini — image generation/editing, chat and file analysis via browser cookies.
No API keys. Free.
Features
- Image generation from text descriptions (Pro model with aspect ratio support)
- 2x resolution — automatically downloads upscaled version (2816x1536 instead of 1408x768)
- 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 — LaMa neural network removes Gemini's sparkle mark locally
- 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[watermark] @ 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
uv run gemini-webapi-mcp
3. Add MCP config
Add to ~/.config/mcp/mcp_servers.json:
From GitHub:
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "gemini-webapi-mcp[watermark] @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git", "gemini-webapi-mcp"]
}
}
}
Without watermark removal: replace
gemini-webapi-mcp[watermark]withgemini-webapi-mcp.
Local (after cloning):
{
"mcpServers": {
"gemini": {
"command": "uv",
"args": ["run", "--with", "/path/to/gemini-webapi-mcp", "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
mcp-cli call gemini gemini_chat '{"prompt": "Hello!"}'
Authentication
The server reads cookies from Chrome automatically via browser-cookie3.
Multiple Google accounts? Auto-detection picks an unpredictable account. Use env vars
GEMINI_PSID/GEMINI_PSIDTSto explicitly select the desired account.
If auto-detection fails or you have multiple accounts, set cookies 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[watermark] @ 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 |
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) |
|---|---|---|
| Pro (16:9) | 1408x768 | 2816x1536 |
| Pro (9:16) | 768x1408 | 1536x2816 |
| Pro (1:1) | 1024x1024 | 2048x2048 |
| Flash | 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 automatically removes it using the LaMa neural network.
Install:
# From GitHub — with watermark removal support
uv run --with "gemini-webapi-mcp[watermark] @ git+https://github.com/AndyShaman/gemini-webapi-mcp.git" gemini-webapi-mcp
# Or separately, if already installed
pip install onnxruntime
On first run, the LaMa model (208 MB) is automatically downloaded and cached in ~/.cache/gemini-mcp/. If onnxruntime is not installed, the server works normally — it just doesn't remove the watermark.
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-pro | image generation | Supports aspect ratios |
gemini-3.0-flash-thinking | — | Shows reasoning process |
Usage Examples
Generate an image:
mcp-cli call gemini gemini_generate_image '{"prompt": "a cat in watercolor style"}'
Edit an image:
mcp-cli call gemini gemini_generate_image '{"prompt": "make it gray", "files": ["/path/to/cat.png"]}'
Analyze a YouTube video or URL:
mcp-cli call gemini gemini_analyze_url '{"url": "https://youtube.com/watch?v=...", "prompt": "Summarize this video"}'
Analyze a file:
mcp-cli call gemini gemini_upload_file '{"file_path": "/path/to/video.mp4", "prompt": "What happens here?"}'
Acknowledgements
This project is built on top of gemini-webapi by @HanaokaYuzu — a reverse-engineered async Python wrapper for the Google Gemini web app. Licensed under AGPL-3.0.
License
AGPL-3.0 — free to use, modify, and distribute, provided the source code remains open.