Metadata-Version: 2.4
Name: pixelforge-mcp
Version: 0.12.0
Summary: MCP server for image and video generation, editing and analysis with Google Gemini models
Author-email: Ahmed Al-Eryani <ahmed@tehnolabs.com>
License-Expression: AGPL-3.0-or-later
Project-URL: Homepage, https://github.com/tehnolabs/pixelforge-mcp
Project-URL: Repository, https://github.com/tehnolabs/pixelforge-mcp
Project-URL: Bug Tracker, https://github.com/tehnolabs/pixelforge-mcp/issues
Keywords: mcp,image-generation,gemini,ai,model-context-protocol
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Software Development :: Libraries
Classifier: Framework :: Pydantic :: 2
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: certifi>=2026.11.20
Requires-Dist: fastmcp<5.0.0,>=4.2.6
Requires-Dist: google-genai<4.0.0,>=3.6.1
Requires-Dist: mcp<3.0.0,>=2.3.0
Requires-Dist: pillow<14.0.0,>=12.0.0
Requires-Dist: pydantic<3.0.0,>=2.12.5
Requires-Dist: pyyaml<7.0.0,>=6.0.2
Provides-Extra: dev
Requires-Dist: pytest<10.0.0,>=8.4.0; extra == "dev"
Requires-Dist: pytest-asyncio<2.0.0,>=1.0.0; extra == "dev"
Requires-Dist: black>=26.1.0; extra == "dev"
Requires-Dist: ruff>=0.15.0; extra == "dev"
Requires-Dist: mypy<3.0.0,>=2.0.0; extra == "dev"
Requires-Dist: types-PyYAML>=6.0.12.20250915; extra == "dev"
Requires-Dist: jsonschema<5.0.0,>=4.23.0; extra == "dev"
Provides-Extra: vertex
Dynamic: license-file

[![PyPI version](https://img.shields.io/pypi/v/pixelforge-mcp)](https://pypi.org/project/pixelforge-mcp/)
[![Python versions](https://img.shields.io/pypi/pyversions/pixelforge-mcp)](https://pypi.org/project/pixelforge-mcp/)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)

# PixelForge MCP

<!-- mcp-name: io.github.Tehnolabs/pixelforge-mcp -->

<p align="center">
  <img src="https://raw.githubusercontent.com/Tehnolabs/pixelforge-mcp/main/docs/assets/hero.png" alt="PixelForge MCP" width="600">
</p>

An MCP server for AI-powered image and video generation, editing, analysis, and transformation using Google's Gemini models. It works with any MCP client.

## Features

- **MCP tools** for image and video generation, editing, analysis, transformation, and more
- **Stable Gemini image models** (Nano Banana 2.1, 2 Lite, 2, and Pro) plus configurable analysis models
- **Quality presets** (fast/balanced/quality) for simplified model selection
- **Parallel multi-image generation** via asyncio.gather
- **Image transforms** — crop, resize, rotate, flip, blur, sharpen, grayscale, watermark
- **Prompt template library** — curated templates, browsable by category
- **Generation history** — every call of a tool that writes files is logged, success or failure, and returns a `generation_id`; browse with `list_history`, look one up with `get_generation_details`
- **Batch processing** — generate up to 10 images in parallel
- **Generative upscale and mode-driven editing** — upscale to the next 1K/2K/4K tier, inpaint, outpaint, background swap, style transfer, product shots
- **Two backends** — Gemini API key, or Vertex AI with a service account / Application Default Credentials
- **Thinking mode & grounding** — extended reasoning and Google Search for analysis
- Standard and panoramic aspect ratios and temperature control
- Async-first architecture with full Pydantic validation; image encoding, transforms, file reads and history writes run in worker threads, so other calls keep answering
- Generation metadata in each saved image: PNG text chunks (prompt, model, aspect ratio, temperature, timestamp) or EXIF in JPEG/WEBP (prompt, model); JPEG saved at quality 95

## Quick Start

**Requirements:** Python 3.11+ and a [Google API key](https://aistudio.google.com/apikey) or a Google Cloud project with Vertex AI (see [Authentication](#authentication))

### Install

The quickest route in Claude Code, Codex or Cursor is the plugin, which starts the server with `uvx pixelforge-mcp@latest` (needs [uv](https://docs.astral.sh/uv/getting-started/installation/)) and adds workflow skills:

```bash
# Claude Code
/plugin install pixelforge --marketplace Tehnolabs/pixelforge-mcp

# Codex
codex plugin marketplace add Tehnolabs/pixelforge-mcp && codex plugin add pixelforge@pixelforge

# Cursor: Customize -> From GitHub Repository -> https://github.com/Tehnolabs/pixelforge-mcp
```

See [plugins/pixelforge/README.md](plugins/pixelforge/README.md) for credentials per client and the skill list. For any other client, or a manual setup, install the server once:

```bash
pipx install pixelforge-mcp
```

### Configure

PixelForge is a stdio MCP server, so any MCP client can run it with the `pixelforge-mcp` command. The examples below use a Gemini API key. To use a Google Cloud service account instead, replace `GOOGLE_API_KEY` with `GOOGLE_CLOUD_PROJECT` and `GOOGLE_APPLICATION_CREDENTIALS` as shown in [Use a service account instead of an API key](#use-a-service-account-instead-of-an-api-key).

#### Claude Code

```bash
claude mcp add pixelforge --scope user -e GOOGLE_API_KEY="your-key" -- pixelforge-mcp
```

#### Claude Desktop

Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "pixelforge": {
      "command": "pixelforge-mcp",
      "env": {
        "GOOGLE_API_KEY": "your-key"
      }
    }
  }
}
```

Restart Claude Desktop after saving.

#### Codex

```bash
codex mcp add pixelforge --env GOOGLE_API_KEY="your-key" -- pixelforge-mcp
```

#### Cursor

Add to `.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "pixelforge": {
      "command": "pixelforge-mcp",
      "env": {
        "GOOGLE_API_KEY": "your-key"
      }
    }
  }
}
```

#### Kiro

```bash
kiro-cli mcp add --name pixelforge --scope global --command pixelforge-mcp --env "GOOGLE_API_KEY=your-key"
```

#### VS Code

```bash
code --add-mcp '{"name":"pixelforge","command":"pixelforge-mcp","env":{"GOOGLE_API_KEY":"your-key"}}'
```

#### Windsurf

Add to `~/.codeium/windsurf/mcp_config.json`:

```json
{
  "mcpServers": {
    "pixelforge": {
      "command": "pixelforge-mcp",
      "env": {
        "GOOGLE_API_KEY": "your-key"
      }
    }
  }
}
```

### Use

Ask your agent to generate, edit, or analyze images and video. The tools are available automatically once the server is connected.

## Authentication

PixelForge talks to Google through one of two backends. Every tool runs on either.

### Gemini API key

Set any one of these variables. Get a key at [Google AI Studio](https://aistudio.google.com/apikey).

| Variable | Notes |
|----------|-------|
| `GOOGLE_API_KEY` | Standard |
| `GOOGLE_GENERATIVE_AI_API_KEY` | Alternative |
| `GEMINI_API_KEY` | Alternative |

### Vertex AI

Use a Google Cloud project with the Vertex AI API enabled and [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials): a service account key file, `gcloud auth application-default login`, or the attached identity when running on Google Cloud. The identity needs the Vertex AI User role (`roles/aiplatform.user`). No extra packages are required.

| Variable | Notes |
|----------|-------|
| `GOOGLE_CLOUD_PROJECT` | Project ID. Setting it enables the Vertex AI backend |
| `GOOGLE_APPLICATION_CREDENTIALS` | Path to a service account key file. Not needed with another ADC source |
| `GOOGLE_CLOUD_LOCATION` | Vertex AI location. Default `global`; the current Gemini image and text models are served from the global endpoint |
| `GOOGLE_GENAI_USE_VERTEXAI` | `true` to use Vertex AI even when an API key is also set (`GOOGLE_GENAI_USE_ENTERPRISE` is accepted as well) |

### Use a service account instead of an API key

A service account runs every tool through Vertex AI, with no Gemini API key. One-time setup with the [gcloud CLI](https://cloud.google.com/sdk/docs/install), using your own project ID:

```bash
PROJECT_ID="YOUR_PROJECT_ID"
SA="pixelforge-sa@${PROJECT_ID}.iam.gserviceaccount.com"

# 1. Enable Vertex AI in the project
gcloud services enable aiplatform.googleapis.com --project="$PROJECT_ID"

# 2. Create the service account and grant it the Vertex AI User role
gcloud iam service-accounts create pixelforge-sa --project="$PROJECT_ID"
gcloud projects add-iam-policy-binding "$PROJECT_ID" \
  --member="serviceAccount:$SA" --role="roles/aiplatform.user"

# 3. Create a key file outside any repository
mkdir -p ~/.config/pixelforge
gcloud iam service-accounts keys create ~/.config/pixelforge/service-account.json \
  --iam-account="$SA"
```

Then configure your client with the project and the key path in place of `GOOGLE_API_KEY`. Claude Code:

```bash
claude mcp add pixelforge --scope user \
  -e GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID" \
  -e GOOGLE_APPLICATION_CREDENTIALS="$HOME/.config/pixelforge/service-account.json" \
  -- pixelforge-mcp
```

Codex:

```bash
codex mcp add pixelforge \
  --env GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID" \
  --env GOOGLE_APPLICATION_CREDENTIALS="$HOME/.config/pixelforge/service-account.json" \
  -- pixelforge-mcp
```

Claude Desktop, Cursor, Windsurf and other JSON-configured clients take the same two variables in the `env` block:

```json
{
  "mcpServers": {
    "pixelforge": {
      "command": "pixelforge-mcp",
      "env": {
        "GOOGLE_CLOUD_PROJECT": "YOUR_PROJECT_ID",
        "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account.json"
      }
    }
  }
}
```

Verify by asking your client for `get_server_info`: `backend.name` should be `vertex_ai`. Commands for every client are in [docs/configuration.md](docs/configuration.md#use-a-service-account-instead-of-an-api-key).

- An API key variable set anywhere in the environment (a shell profile, for example) takes precedence, and the service account is ignored. Unset it, or add `"GOOGLE_GENAI_USE_VERTEXAI": "true"` to the same `env` block.
- The key file grants access to your project. Keep it out of version control, give the service account only `roles/aiplatform.user`, and delete keys you no longer use (`gcloud iam service-accounts keys list --iam-account="$SA"`).
- No key file is needed when credentials come from `gcloud auth application-default login` (optionally with `--impersonate-service-account="$SA"`) or from the attached identity on Google Cloud. Set only `GOOGLE_CLOUD_PROJECT` in that case.

### Backend selection

- An API key selects the Gemini API.
- `GOOGLE_CLOUD_PROJECT` with no API key selects Vertex AI.
- Both set: the API key wins unless `GOOGLE_GENAI_USE_VERTEXAI=true`.

`get_server_info` reports the active backend under `backend.name`.

The Google client is created on the first tool call that needs it, so startup and `get_server_info` need no credentials, and it is closed when the session ends; the next session in the same process creates a new one.

### File access

Generated files go to one output directory, and `get_server_info` reports it as an absolute path under `storage.output_directory`. These optional variables control file access from the server side:

| Variable | Default | Effect |
|----------|---------|--------|
| `PIXELFORGE_OUTPUT_DIR` | `generated_images` under the server's working directory | Where every tool writes |
| `PIXELFORGE_ALLOWED_INPUT_DIRS` | Off | Folders input images and videos must come from (`:`-separated, `;` on Windows); the output directory is always readable |
| `PIXELFORGE_CONFIG` | `config/config.yaml` | YAML configuration file (standalone installs) |
| `PIXELFORGE_RESOURCE_LINKS` | Off | `1` adds a `resource_link` (`file://` URI, name, MIME type, size) for each saved image or video after the JSON text of a tool result. Host support varies, so it is off by default |

A tool given an `output_filename` that already exists fails before calling Google unless you pass `overwrite=true`. Input images must be real PNG, JPEG or WEBP files up to 70 MB; videos up to 70 MB, since a video is sent base64-encoded inside Google's 100 MB request limit. Details: [File access](docs/configuration.md#file-access).

## Available Tools

### Generation

| Tool | Description |
|------|-------------|
| `generate_image` | Generate images from text (model choice, quality presets, standard and panoramic aspect ratios, parallel multi-image) |
| `edit_image` | Modify existing images with text prompts |
| `remove_background` | Remove image background (subject on flat white, no alpha channel) |
| `transform_image` | Crop, resize, rotate, flip, blur, sharpen, grayscale, or watermark |
| `batch_generate` | Generate up to 10 images in parallel from multiple prompts (all inputs checked before any call; each prompt logged to history with its own `generation_id`) |
| `upscale_image` | Generative upscale to the next 1K/2K/4K tier (re-render with a Gemini image model) |
| `advanced_edit` | Inpainting, outpainting, background swap, style transfer, product shots (prompt-driven, optional mask guidance) |
| `generate_video` | Generate 3-15s MP4 video + stereo audio via `gemini-omni-1.2-flash` (`360p`/`720p`/`1080p`/`4K`, frame interpolation, up to 6 reference images) |
| `edit_video` | Edit, extend (3-10s up to 30s), or upscale video clips via `gemini-omni-1.2-flash` |

### Analysis

| Tool | Description |
|------|-------------|
| `analyze_image` | AI-powered image description with optional grounding and `model` override |
| `extract_text` | OCR — extract text with confidence levels |
| `detect_objects` | Detect objects with bounding boxes |
| `compare_images` | Compare 2-10 images for differences |
| `evaluate_image` | Calibrated `noul` (yes/no), `choice` (A/B/N), and `score` rubric QA on 1-10 images via `gemini-decision-1` (Gemini API `v1beta`) |

Analysis tools and `optimize_prompt` accept a `model` override and optional `thinking_level` (`minimal`, `low`, `medium`, `high`, `xhigh`). The default is `gemini-3.5-flash-lite`; use `gemini-4-hydrogen`, `gemini-4-neon`, `gemini-4-argon`, `gemini-4-carbon`, `gemini-3.8-flash`, or `gemini-3.6-flash` for harder OCR or reasoning.

### Utility

| Tool | Description |
|------|-------------|
| `optimize_prompt` | Enhance prompts for better image generation (selectable styles) |
| `estimate_cost` | Calculate costs per model for generate, edit, analyze, evaluate or video (video per default 5 s 720p clip) |
| `list_templates` | Browse curated prompt templates by category |
| `apply_template` | Fill a template with your subject for a ready-to-use prompt |
| `list_available_models` | Model capabilities, speed, quality, and selection guidance |
| `get_server_info` | Server configuration and status |

### History

| Tool | Description |
|------|-------------|
| `list_history` | Browse generation history, newest first (1-100 entries per page, optional tool filter) |
| `get_generation_details` | Get one history entry by the `generation_id` a tool returned |

Every call of `generate_image`, `edit_image`, `remove_background`, `transform_image`, `upscale_image`, `advanced_edit`, `generate_video` and `edit_video` is one history entry, and `batch_generate` logs one entry per prompt. Failures are logged too (`success: false` with the `error`), including invalid input, billed-call refusals and tool timeouts; a cancelled call returns nothing and is not logged. An argument FastMCP rejects before the tool runs (wrong type, missing or unknown) and an unexpected crash, which reaches the client only as `Error calling tool '<name>'`, are logged with `success: false` and the error too, but the client gets no `generation_id` for them; find them with `list_history`. Each of these tools returns the entry's `generation_id` (a 32-character hex ID) on success and on failure; `batch_generate` returns one per `results[]` item, and a top-level one only when it stopped before any prompt ran. Entries record the call's arguments, the saved files (or the `gs://` `video_uri`), the model, the error and a UTC timestamp. They stay in `.pixelforge_history.json` in the output directory until you delete that file. See [Generation history](docs/configuration.md#generation-history).

### Results

Every tool advertises a typed `outputSchema`, and every success returns structured content that matches it, with a JSON text copy. All results carry `success` and `message` (analysis and utility tools now set `message` on success too) and an optional `warnings` list. The image tools (`generate_image`, `edit_image`, `remove_background`, `transform_image`, `upscale_image`, `advanced_edit`) share one shape: `images[]` with the absolute `path`, `size_bytes` and `mime_type` of each saved file, so read `images[0].path` from any of them. `output_path` (on `transform_image`, `upscale_image` and `advanced_edit`) and the top-level `size_bytes` of `transform_image` are deprecated aliases kept for one minor release. `generate_video` and `edit_video` return `video_path` or `video_uri`; `batch_generate` returns `results[]` with one `output_path` or `error` per prompt; `get_generation_details` returns the history entry under `entry` (its keys are also copied to the top level for one minor release). The tools that write files also return `generation_id`, on failures too. A file the API reported as saved but that is not on disk is never dropped silently: a single-output call fails, a multi-image `generate_image` reports it in `errors` with `partial_failure`, and a `batch_generate` item fails. Model-generated lists (`extract_text` `blocks`, `detect_objects` `detections`, `evaluate_image` `answers`) declare the fields they usually carry and allow any other key. See [Result schemas](docs/configuration.md#result-schemas).

### Errors

A call that fails inside a tool comes back as an MCP error result (`isError: true`). Its structured content and text block carry the same payload every tool has always used: `{"success": false, "message": "..."}`, plus tool-specific fields such as `errors` (`generate_image`), `results` (`batch_generate`) or `available_templates` (`apply_template`). Arguments that pass the type checks but fail a tool's validation rules read `Invalid input: <field>: <reason>` with that payload; a list item names its position, as in `Invalid input: prompts[1]: Prompt cannot be empty`. Arguments of the wrong type and missing required arguments are rejected by the MCP framework before the tool runs: they come back as `isError: true` with plain text from the framework, no structured content and no `success` field. Partial successes are not errors: `generate_image` with `partial_failure` and a `batch_generate` run with at least one image keep `isError: false` and `success: true`. An unexpected server bug is reported as `Error calling tool '<name>'`; the details stay in the server log on stderr. The log goes to stderr only, at `server.log_level` (default `INFO`), and records prompt text only at `DEBUG`; see [Logging](docs/configuration.md#optional-yaml-configuration-file).

### Progress

Generations, upscales, batches and video renders can take minutes. When the client sends a `progressToken` with the call, these tools send `notifications/progress` while they run:

- `batch_generate` and `generate_image` with more than one image: one step per finished image, failed ones included, out of the total (`2/3 images generated`)
- `generate_image` with one image, `edit_image`, `remove_background`, `upscale_image` and `advanced_edit`: a start step (0 of 1) and an end step (1 of 1)
- `generate_video` and `edit_video`: elapsed seconds every 10 seconds while the request is pending, with no total, because the API gives no intermediate signal

Nothing is sent when the call carries no `progressToken`, and no notification follows the result. Tool results do not change. Cancelling a call (for example a client timeout) cancels its requests to Google, and a cancelled `batch_generate` logs only the images that finished before the cancellation to history. See [Progress notifications](docs/configuration.md#progress-notifications).

### Time limits

Every tool that calls Google is bounded. Each request to Google times out when a connect, send or read wait exceeds 90 seconds (300 seconds for video), and is tried up to 5 times (twice for video, since every video attempt may be billed). The tool itself stops after 600 seconds (720 seconds for `generate_video` and `edit_video`), a hard upper bound set above the usual worst case of those attempts. Raise the per-attempt limits with `PIXELFORGE_HTTP_TIMEOUT_SEC` and `PIXELFORGE_VIDEO_HTTP_TIMEOUT_SEC` (10-1800 seconds); the tool timeouts follow, and `get_server_info` reports them under `timeouts`. The plugin sets the Codex and Claude Code tool timeouts to 960 seconds so the host does not give up first. See [Time limits](docs/configuration.md#time-limits).

### Billed-call limits

A runaway agent loop cannot run up an unbounded bill. The tools that call Google share two limits; local tools (`transform_image`, templates, history, `estimate_cost`, `list_available_models`, `get_server_info`) are never limited:

| Variable | Default | Effect |
|----------|---------|--------|
| `PIXELFORGE_MAX_CONCURRENT_BILLED_CALLS` | `4` | Billed tool calls that run at once. A call that finds every slot taken waits up to 30 seconds, then fails. `0` turns the limit off |
| `PIXELFORGE_MAX_BILLED_UNITS_PER_MINUTE` | `60` | Billed units admitted in any 60 seconds. A unit is one image (`generate_image` counts `number_of_images`, `batch_generate` its prompts), one analysis, evaluation or prompt call, or one second of video (`generate_video` `duration_seconds`; `edit_video` `duration_seconds`, or 10 when not given). `0` turns the limit off |

A call over either limit returns an error result (`isError: true`) with `{"success": false, "message": "...", "retry_after_seconds": <n>}` and makes no request to Google; a single call larger than the whole per-minute budget gets `retry_after_seconds: null`, since waiting cannot help. Units are charged when a call is admitted, so a call that later fails still counts. YAML takes the same settings under `limits:`; `get_server_info` reports them under `limits`. See [Billed-call limits](docs/configuration.md#billed-call-limits).

### Parameter schemas

Each tool's `inputSchema` lists the allowed values and limits, so a model can pick a valid value without guessing. Closed sets carry an `enum`: aspect ratios, `output_format`, `image_size`, `quality`, `thinking_level`, `grounding`, `safety_setting`, transform `operation`, flip `direction` and watermark `position`, `upscale_factor`, `edit_mode`, prompt `style`, cost `operation`, and the video `aspect_ratio`, `resolution` and `task`. Numbers and lists carry `minimum`/`maximum`, `minItems`/`maxItems` or `minProperties`/`maxProperties`, for example `number_of_images` 1-4, `temperature` 0-2, `duration_seconds` 3-15, `compare_images` 2-10 paths and `batch_generate` 1-10 prompts. Every parameter has a description. `model` stays a free-form string that lists the known IDs under `examples`, so a retired or deprecated ID still gets a message naming its replacement. The tools still accept the letter-case variants they always normalised (`"PNG"`, `"1k"`, `"X2"`); a value outside a closed set or a limit comes back as an `Invalid input: <field>: <reason>` error result from the tool, except the `list_history` `limit` and `offset` bounds, which the MCP framework enforces before the tool runs.

### Tool annotations

Every tool declares MCP annotations so hosts can decide when to ask for confirmation and which calls may run in parallel:

| Hints | Tools |
|-------|-------|
| Read-only, local | `estimate_cost`, `list_templates`, `apply_template`, `list_history`, `get_generation_details`, `list_available_models`, `get_server_info` |
| Read-only, sends data to Google | `analyze_image`, `extract_text`, `detect_objects`, `compare_images`, `evaluate_image`, `optimize_prompt` |
| Writes new files, calls Google | `batch_generate` |
| Can replace a file named by `output_filename` when `overwrite=true`, calls Google | `generate_image`, `edit_image`, `remove_background`, `upscale_image`, `advanced_edit`, `generate_video`, `edit_video` |
| Can replace a file named by `output_filename` when `overwrite=true`, local | `transform_image` |

Tools that call Google carry the `billed` tag, and every tool has one group tag (`generation`, `video`, `analysis`, `utility` or `history`). Read-only analysis tools may run without a confirmation prompt in some hosts even though they upload the image and are billed: see [Tool annotations](docs/configuration.md#tool-annotations).

### Response caching

The tool list never changes while the server runs, so on the 2026-07-28 protocol `tools/list` and `server/discover` carry a cache hint (`ttlMs` 3600000, `cacheScope` `private`): a client with response caching on may reuse the list for up to an hour. Older clients see no change. See [Response caching](docs/configuration.md#response-caching).

## Model Selection

PixelForge supports **per-request model switching** with stable Gemini image models:

### Image Models

| Use case | Model | Why |
|----------|-------|-----|
| General use (default) | `gemini-nano-banana-2.1` | 1K/2K/4K, `web` + `web_and_image` grounding, `thinking_level` (`minimal`/`medium`/`high`), 1:4/4:1/1:8/8:1, up to 14 image refs + `reference_video`. $0.0336/img at 1K |
| Fastest, cheapest | `gemini-3.1-flash-lite-image` | 1K only, no panoramic, no grounding, supports `reference_video`. $0.0336/img |
| Max text fidelity | `gemini-3-pro-image` | Best text rendering, complex multi-turn edits, `web` grounding. $0.134/img at 1K/2K |
| Deprecated (`0.5K` tier) | `gemini-3.1-flash-image` | Deprecated 2026-10-06 (use `gemini-nano-banana-2.1`); still active for `0.5K` rapid iteration ($0.045/img at 0.5K) |

`gemini-2.5-flash-image` is deprecated (shutdown announced for `2027-03-15`) and remains only for existing setups; use `gemini-3.1-flash-lite-image` instead. Retired preview IDs (`gemini-2.5-flash-image-preview`, `gemini-2.0-flash-preview-image-generation`, `imagen-4.0-*`) fail fast with a migration hint.

`0.5K` is `gemini-3.1-flash-image` only and is sent to the API as `512px`. `generate_image` rejects a size the chosen model cannot output.

`upscale_image` and `advanced_edit` re-render with `gemini-nano-banana-2.1` unless `model` is set. `upscale_image` outputs the smallest of 1K/2K/4K that covers the source times the factor (capped at 4K) and needs a model with 2K/4K output (`gemini-nano-banana-2.1`, `gemini-3.1-flash-image`, or `gemini-3-pro-image`); `gemini-3.1-flash-lite-image` is rejected. Both tools pin the nearest aspect ratio the model supports; models without panoramic output get a standard ratio and a warning.

### Analysis Models (text)

Used by `analyze_image`, `extract_text`, `detect_objects`, `compare_images`, and `optimize_prompt`. Override per request with `model=` and `thinking_level=`.

| Model | Notes |
|-------|-------|
| `gemini-3.5-flash-lite` (default) | Everyday low-cost analysis; $0.30 in / $2.50 out per 1M tokens |
| `gemini-3.6-flash` | Balanced Gemini 3.6 workhorse; $0.75 in / $3.75 out per 1M tokens |
| `gemini-3.8-flash` | Strong OCR & detection; $0.75 in / $3.75 out per 1M tokens |
| `gemini-4-hydrogen` | Gemini 4 daily driver (`thinking_level` up to `xhigh`); $1.50 in / $7.50 out per 1M tokens |
| `gemini-4-neon` | Dense OCR, diagrams, charts & UI (`thinking_level` up to `xhigh`); $3.00 in / $15.00 out per 1M tokens |
| `gemini-4-argon` | Token-efficient frontier Gemini 4 reasoning (`low`/`medium`/`high`); $4.00 in / $20.00 out per 1M tokens |
| `gemini-4-carbon` | Strongest Gemini 4 multimodal reasoning (`low`/`medium`/`high`); $4.00 in / $20.00 out per 1M tokens |

### Quality Presets

Instead of choosing a model manually, use quality presets:

```
generate_image(prompt="...", quality="fast")      # gemini-3.1-flash-lite-image
generate_image(prompt="...", quality="balanced")   # gemini-nano-banana-2.1 + 1K
generate_image(prompt="...", quality="quality")    # gemini-3-pro-image + 2K
```

## Supported Aspect Ratios

| Ratio | Description |
|-------|-------------|
| `1:1` | Square (default) |
| `16:9` | Widescreen landscape |
| `9:16` | Mobile portrait |
| `2:3` | Classic portrait |
| `3:2` | Classic landscape |
| `3:4` | Portrait |
| `4:3` | Traditional landscape |
| `4:5` | Instagram portrait |
| `5:4` | Medium format |
| `21:9` | Ultrawide |
| `1:4` | Tall panoramic* |
| `4:1` | Wide panoramic* |
| `1:8` | Extra tall panoramic* |
| `8:1` | Extra wide panoramic* |

\* Panoramic ratios require `gemini-nano-banana-2.1` or `gemini-3.1-flash-image`

## Troubleshooting

### "Invalid API key" or "Authentication failed"

Double-check your Google API key is correct and has access to the Gemini API. Get a key at [Google AI Studio](https://aistudio.google.com/apikey). If you meant to use a service account, an API key variable set anywhere in the environment takes precedence: unset it or set `GOOGLE_GENAI_USE_VERTEXAI=true`.

### "Command not found: pixelforge-mcp"

Ensure the pipx bin directory is in your PATH:

```bash
export PATH="$HOME/.local/bin:$PATH"
```

### "Server not starting"

Check that pixelforge-mcp is installed:

```bash
pipx list | grep pixelforge
```

### "Publisher model ... was not found" (Vertex AI)

With a regional location in the message, the request went to a regional Vertex AI endpoint. The current Gemini image and text models are served from the global endpoint: set `GOOGLE_CLOUD_LOCATION=global` (the default) or remove a regional override. With `locations/global` in the message, the model ID is unknown or retired on Vertex AI (`list_available_models` lists current IDs), or the project cannot access it yet. The same 404 is returned for retired Imagen model IDs, which PixelForge no longer calls.

### "Rate limit exceeded" or "Permission denied"

The message carries Google's own text. A quota `limit: 0`, or "has not been used in project ... or it is disabled", is a project setup limit rather than a model problem: enable the Vertex AI API (or the Generative Language API for an API key), grant `roles/aiplatform.user`, or request a quota increase.

### "timed out"

The request to Google or the tool ran past its time limit. The message says so and warns that the request may still have been processed and billed: check the output directory before retrying. If large renders (4K, `gemini-3-pro-image`, long videos) keep timing out, raise `PIXELFORGE_HTTP_TIMEOUT_SEC` or `PIXELFORGE_VIDEO_HTTP_TIMEOUT_SEC` and your client's tool timeout with it. See [Time limits](docs/configuration.md#time-limits).

### "Billed-unit limit reached" or "Concurrent billed-call limit reached"

PixelForge's own guard refused the call before any request to Google. Wait `retry_after_seconds` and retry, or raise `PIXELFORGE_MAX_BILLED_UNITS_PER_MINUTE` or `PIXELFORGE_MAX_CONCURRENT_BILLED_CALLS` (`0` turns a limit off). See [Billed-call limits](docs/configuration.md#billed-call-limits).

### "No credentials found"

Set an API key, or `GOOGLE_CLOUD_PROJECT` with Application Default Credentials. See [Authentication](#authentication).

## Documentation

- [Plugin for Claude Code, Codex and Cursor](plugins/pixelforge/README.md) and [ADR-004](docs/adr/004-agent-plugins-and-skills.md) on how the bundle is laid out

- [Configuration Guide](docs/configuration.md) — detailed setup and environment options
- [`server.json`](server.json) — the entry for the official [MCP Registry](https://registry.modelcontextprotocol.io) (`io.github.Tehnolabs/pixelforge-mcp`), published with each release
- [Changelog](CHANGELOG.md) — version history

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, code standards, and pull request guidelines.

## License

[AGPL-3.0](LICENSE)

## Acknowledgments

Built with [FastMCP](https://github.com/jlowin/fastmcp), [Pydantic](https://docs.pydantic.dev/), and [google-genai](https://github.com/googleapis/python-genai).

## Author

Ahmed Al-Eryani @ Tehnolabs

---

**PixelForge MCP** - Forging pixels with AI
