pixel-surgeon-mcp is an MCP (Model Context Protocol) server that provides image and video generation, editing, and regional inpainting capabilities for Claude or any MCP client, all through natural language.
Purpose It is aimed at scenarios that need to directly produce or modify images and videos within conversational AI workflows. Core uses include: generating images, editing images, fixing garbled or incorrect text in images, and creating videos with ambient audio.
Main capabilities Multi-provider support, switchable per request:
- Gemini (Google): balanced. Uses a two-stage process, with Gemini 3.1 Pro reasoning over the prompt and Gemini 3.1 Flash Image rendering the pixels. Supports 9 aspect ratios, with resolutions of 512/1K/2K/4K. Best cost-performance, with a free tier.
- OpenAI GPT Image 2: highest quality. Significantly improved text rendering and visual fidelity, supports flexible resolutions, and automatically maps the selected size and aspect ratio to the optimal pixel dimensions. Quality levels include medium (fast) and high (print-grade). Suitable for infographics, charts, and text-dense images. Slower and more expensive.
- Grok Imagine (xAI): fastest. Based on the Aurora image model, it offers the fastest generation and lowest cost. Supports 7 aspect ratios, with a fixed resolution (about 1K). Suitable for rapid prototyping and iteration.
- Video: calls Veo 3, with asynchronous polling, generating video and ambient audio at the same time. Supports 16:9 and 9:16, with durations of 5 seconds or 8 seconds.
Style presets All generation and editing tools support an optional style parameter. Built-in presets include: magazine editorial style (bold typography, halftone texture, cream/black/terracotta tones), duval-software-infographic (retro-futuristic infographic, combining 1960s space age with 1980s arcade, cathode blue/amber/salmon tones, suitable for charts and system overviews), dither fractal/Sierpinski patterns/low-poly (CRT retro, Amiga/EGA palette), clean-tech-infographic (technical diagrams, system flows, data pipelines, deep navy/cyan/electric blue).
Text repair and regional inpainting AI image models are prone to errors when handling text-dense images. The repair tool sends smaller regions to the provider, then uses histogram matching compositing to stitch the results back intoGo, achieve seamless blending.
Model selection and fallback You can force a specific model via the per-call model tool parameter, or set the DEFAULT_IMAGE_MODEL environment variable. If a Gemini generation call fails due to a billing/prepaid error, the server automatically retries with the free-tier gemini-2.5-flash-image model, and the viewer displays a yellow banner. Free-tier limits: up to 1K resolution, 10 RPM, 500 RPD.
Usage Requires at least one provider's API key, in any combination.
- Google: Go to Google AI Studio, sign in with a Google account, click Create API Key and copy it. Note that Gemini 3.1 Flash Image and Veo 3 require billing and prepaid credits; the free-tier fallback (2.5 Flash) has limited resolution and rate.
- OpenAI: Go to OpenAI API, sign in or create an account, click Create new secret key and copy it. Make sure you have API credits; image generation is billed per request.
- xAI: Go to the xAI Console, create an API key and copy it. Quick start (npx): No installation needed, run directly with npx and pass in the API keys you have. Install from source: You can clone locally. Generated images are saved to ~/Pictures/pixel-surgeon/. On first use, a local browser viewer starts automatically, supporting full-resolution preview, model selection, regeneration controls and search.
Key implementation details
- Aspect ratio snapping: Crops are adjusted to the nearest Gemini-supported ratio while preserving the center point.
- Histogram matching: Per-channel RGB normalization ensures seamless blending of the composited area.
- Human in the loop: interactive_fix opens a browser cropping UI, blocks via a Promise until the user submits, and issues Gemini calls in parallel so the user can pick the best result.
- MCP size limit: Full-resolution images are saved to disk, and a downsampled version (under 950KB) is returned in the MCP response.
Use cases Suitable for quickly generating images via natural language in MCP clients such as Claude, creating infographics and charts, fixing text errors, performing region-level image inpainting, and generating short videos with audio. Multi-provider switching makes it easy to balance quality, speed and cost.
Limitations
- Requires at least one provider's API key; some models require billing and prepaid credits.
- Grok Imagine output resolution is fixed (about 1K), with no size control.
- GPT Image 2 is slower and more expensive.
- The Gemini free-tier fallback has resolution and rate limits.
- Video only supports 16:9 and 9:16, 5 seconds or 8 seconds.
- Currently supports Gemini, OpenAI, Grok Imagine and Veo 3; adapters for other image/video generation APIs are not yet available.
The project is maintained by John Evans of Duval Software, and PRs for new style presets and adapters are welcome.