Imagen
MCP server for generating pixel-art sprites with transparent backgrounds using any diffusers-compatible text-to-image model.
README
Imagen
MCP server for generating pixel-art sprites with transparent backgrounds. Bring your own model — any diffusers-compatible text-to-image pipeline works.
The default configuration uses FLUX.2-klein-4B + pixel-art-lora, but you can swap in any model you like.
Features
- Bring your own model — any diffusers-compatible pipeline (FLUX, SDXL, SD3, etc.)
- Text-to-sprite generation — describe any character, get a pixel-art PNG
- Transparent background — automatic background removal via flood-fill
- Pixel-art effect — downscale/upscale with NEAREST interpolation
- Reproducible — optional seed for consistent results
- Batch generation — generate multiple sprites in one call
- MCP integration — works with any MCP-compatible client (opencode, Claude, etc.)
- Feedback loop — rate generated sprites, AI uses high-rated ones as reference
Quick Start
1. Install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
2. Download a model
You need a base text-to-image model. Optionally, a LoRA adapter for pixel-art style.
Example: FLUX.2-klein-4B + pixel-art-lora (default)
mkdir -p ~/models
# Base model (~23 GB)
huggingface-cli download black-forest-labs/FLUX.2-klein-4b \
--local-dir ~/models/flux2-klein-4b
# LoRA adapter (~625 MB) — optional but recommended for pixel-art
huggingface-cli download Limbicnation/pixel-art-lora \
--local-dir ~/models/pixel-art-lora
Other models that work:
| Model | Size | LoRA support | Notes |
|---|---|---|---|
| FLUX.2-klein-4B | ~23 GB | Yes | Default, distilled (4 steps) |
| FLUX.1-dev | ~23 GB | Yes | More detail, slower (20+ steps) |
| SDXL | ~7 GB | Yes | Lighter, good for 8 GB VRAM |
| SD3.5-large | ~16 GB | Yes | Good quality/speed balance |
Note: You may need to adjust
LORA_SCALEand pipeline class inserver.pydepending on your model. See Configuration.
3. Configure paths
By default, models are expected at ~/models/. Override with environment variables:
export IMAGEGEN_MODEL_DIR=/path/to/your/base-model
export IMAGEGEN_LORA_DIR=/path/to/your/lora # optional, set empty to disable
export IMAGEGEN_OUTPUT_DIR=/path/to/output
4. Run as MCP server
./venv/bin/python server.py
5. Review & rate sprites (GUI)
./venv/bin/pip install dearpygui pillow
./venv/bin/python review_gui.py
Features:
- Thumbnail preview of each generated sprite
- Star rating (1-5) with one click
- Text feedback per sprite
- Filter: all / unrated / top rated
- Export rated dataset as JSONL for fine-tuning
Or configure in your MCP client:
{
"mcp": {
"pixel-art": {
"type": "local",
"command": ["./venv/bin/python", "server.py"],
"enabled": true
}
}
}
Tools
Generation
generate_sprite
Generate a single pixel-art sprite. Automatically saved to feedback DB (unrated).
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
str | required | Sprite description (e.g. "a brave knight in armor") |
output_path |
str | required | PNG save path (relative to output dir or absolute) |
seed |
int? | null | Seed for reproducibility |
width |
int | 512 | Image width |
height |
int | 512 | Image height |
steps |
int | 4 | Inference steps (lower = faster, less detail) |
remove_bg |
bool | true | Remove background, make transparent |
pixel_size |
int | 4 | Pixel block size (0 = off, 4 = chunky pixel-art) |
Returns: output_path, db_id, generation_time, and other metadata.
batch_generate
Generate multiple sprites in one call. Each is saved to the feedback DB.
Feedback
rate_sprite
Rate a generated sprite 1-5 stars with optional feedback.
| Parameter | Type | Default | Description |
|---|---|---|---|
db_id |
str | required | ID returned by generate_sprite / batch_generate |
rating |
int | required | 1-5 stars |
feedback |
str? | null | Optional text feedback |
get_reference_sprites
Get highly-rated reference sprites for a prompt. The AI uses these as examples when generating similar sprites.
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
str | required | Search query (e.g. "knight") |
limit |
int | 5 | Max results |
min_rating |
int | 4 | Minimum rating threshold |
list_sprites
List sprites in the feedback database.
| Parameter | Type | Default | Description |
|---|---|---|---|
filter |
str | "all" | "all", "unrated", or "top" |
limit |
int | 20 | Max results |
db_stats
Get database statistics: total sprites, rated, unrated, average rating.
Configuration
Environment variables
| Variable | Default | Description |
|---|---|---|
IMAGEGEN_MODEL_DIR |
~/models/flux2-klein-4b |
Path to base model |
IMAGEGEN_LORA_DIR |
~/models/pixel-art-lora |
Path to LoRA adapter |
IMAGEGEN_OUTPUT_DIR |
./output |
Default output directory |
Swapping models
The server is configured for FLUX.2-klein by default. To use a different model, edit server.py:
- Pipeline class — replace
Flux2KleinPipelinewith your model's pipeline (e.g.StableDiffusionXLPipelinefor SDXL) - LoRA scale — adjust
LORA_SCALE(rsLoRA needs ~0.1, regular LoRA typically 0.7-1.0) - Guidance scale — distilled models ignore it; standard models need 5-8
- Steps — distilled models work at 4; standard models need 20-30
How It Works
- Generation — text-to-image model generates a 512x512 image
- Pixelation — downscale with LANCZOS, upscale with NEAREST → chunky pixel-art blocks
- Background removal — detect border color, normalize to solid fill, flood-fill from edges → transparent PNG
Requirements
- GPU: NVIDIA with >= 8 GB VRAM (uses CPU offload automatically)
- Python: 3.12+
- CUDA: 12.0+
Credits
- Default model: FLUX.2-klein-4B by Black Forest Labs (Apache 2.0)
- Default LoRA: pixel-art-lora by Limbicnation (Apache 2.0)
- MCP SDK: modelcontextprotocol/python-sdk
License
MIT — see LICENSE
Model licenses are separate from this project. Check each model's license card for usage terms.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。