Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Animagine MCPOptimize this prompt for Animagine XL: 1girl, solo, sitting in a cafe"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Animagine MCP
FastMCP server for the Animagine XL 4.0 image generation experience, providing prompt validation, optimization, explanation, and checkpoint/LoRA management tools.
For AI Agents: This repository includes comprehensive markdown documentation in
02-behavior/,03-contracts/,04-quality/, and05-implementation/directories. These files contain detailed specifications, behavior rules, prompt taxonomies, and implementation guides optimized for AI agent consumption. If you're building AI-powered workflows or need structured guidance for prompt engineering, check out these resources.
For Humans: Welcome! A few friendly reminders:
Do not commit AI agent files (
.cursor/,.claude/,.copilot/, etc.) — these are already in.gitignoreBe respectful in discussions — we're all here to learn and build together
Help each other — share your knowledge, ask questions, and contribute back
Let's create something amazing together! 🎨
Table of Contents
Overview
Animagine MCP exposes powerful tools through FastMCP (MCP protocol) and FastAPI (REST API):
Prompt Tools:
validate_prompt,optimize_prompt,explain_promptModel Tools:
list_models,load_checkpoint,unload_lorasGeneration Tools:
generate_image,generate_image_from_image
Key features:
Dual API support: Use MCP protocol for AI agents or REST API for web/app integration
Normalizes prompts for consistent structure, category coverage, and tag ordering
Integrates with local checkpoint and LoRA assets
GPU-accelerated image generation with CUDA support
Docker-ready with comprehensive GPU configuration
Interactive API documentation with Swagger UI
Choose Your Interface
Interface | Best For | Port |
MCP Server | Claude Desktop, Cursor, other MCP clients | stdio |
REST API | Web applications, CLI tools, mobile apps | 8000 |
REPL | Interactive testing and development | stdin/stdout |
Note: This platform can generate NSFW material. Choosing to do so and owning the resulting content is the caller's responsibility.
Quick Start Guide
Option 1: Docker (Recommended)
The fastest way to get started with GPU acceleration.
What's Included
Automatic setup: Directories (
checkpoints/,loras/,outputs/) are created automaticallyPre-downloaded model: Animagine XL 4.0 (~6GB) is downloaded during build
GPU acceleration: CUDA 12.1 with optimized PyTorch
REST API: FastAPI server on port 8000 with interactive documentation
Prerequisites
Docker and Docker Compose installed
NVIDIA GPU with drivers installed (verify with
nvidia-smi)NVIDIA Container Toolkit (installation guide)
~15GB disk space (for Docker image + model)
Steps
Step 1: Clone the repository
Step 2: Build and start the container
Note: First build downloads Animagine XL 4.0 (~6GB) and may take 10-20 minutes depending on your connection. Subsequent builds use cached layers.
Step 3: Verify startup (watch logs)
You should see:
Step 4: Access the services
REST API:
API Documentation: http://localhost:8000/docs (Swagger UI)
Alternative docs: http://localhost:8000/redoc (ReDoc)
Health check:
curl http://localhost:8000/health
MCP Server (for Claude Desktop, Cursor, etc.):
Stdio endpoint available to MCP clients
Quick Docker Commands
Command | Description |
| Start the server |
| Stop the server |
| View logs |
| Shell access |
| Rebuild from scratch |
Environment Variables
Variable | Description | Default |
| Skip model verification on startup |
|
Option 1b: REST API Only
If you only want to use the REST API without MCP protocol support:
The API will be available at http://localhost:8000 with full documentation at /docs.
Option 2: Local Installation
For development or systems without Docker.
Prerequisites
Python >= 3.11
GPU with CUDA support (recommended)
gitandpip
Steps
Step 1: Clone and create virtual environment
Step 2: Activate the virtual environment
Windows:
Linux/macOS:
Step 3: Install dependencies
Step 4: Start the MCP server
Step 5: Verify it's running
The server is now exposing tools via FastMCP at the default endpoint.
Option 3: Interactive REPL (Testing)
Test MCP tools interactively without running the full server.
Quick Start
REPL Interface
CLI Options
MCP Client Configuration
To connect an MCP client (like Claude Desktop, VS Code, or other MCP-compatible tools) to this server, create a .mcp.json configuration file.
Example .mcp.json
For local installation:
For development (running from source):
For Docker:
Windows example:
Configuration Options
Field | Description |
| Executable to run ( |
| Command line arguments |
| Working directory (optional) |
| Environment variables (optional) |
Where to Place .mcp.json
Depending on your MCP client:
Claude Desktop:
~/.config/claude/mcp.json(Linux/Mac) or%APPDATA%\Claude\mcp.json(Windows)VS Code: Project root or workspace settings
Other clients: Check client documentation
Core Tools
The same powerful tools are available through both MCP protocol and REST API:
Prompt Tools
Tool | MCP Call | REST Endpoint | Description |
|
|
| Validates prompt against Animagine XL rules |
|
|
| Restructures and optimizes prompt tags |
|
|
| Explains each tag's category and effect |
Model Tools
Tool | MCP Call | REST Endpoint | Description |
|
|
| Lists available checkpoints and LoRAs |
|
|
| Pre-loads a checkpoint to GPU memory |
|
|
| Removes all LoRA weights from pipeline |
Generation Tools
Tool | MCP Call | REST Endpoint | Description |
|
|
| Generates image from prompt |
|
|
| Image-to-image transformation |
Using the REST API
For detailed REST API documentation, see API.md which includes:
Full endpoint reference
Request/response examples
cURL examples
Python client examples
Performance tuning guide
Quick start:
Usage Examples
Example 1: Validate a Prompt
Example 2: Optimize a Natural Language Description
Example 3: Generate an Image
Example 4: Use Custom Checkpoint and LoRA
REST API
For full REST API documentation with detailed examples, see API.md.
Quick Reference
Base URL: http://localhost:8000/api/v1
Interactive Documentation: http://localhost:8000/docs
Common Endpoints:
POST /validate-prompt- Validate a promptPOST /optimize-prompt- Optimize a promptPOST /explain-prompt- Explain prompt tagsGET /models- List available modelsPOST /load-checkpoint- Load a checkpointPOST /generate- Generate an imagePOST /generate-img2img- Transform an image
Example: Generate an image via REST API
Advanced Guide
GPU Acceleration
GPU acceleration provides 10-50x faster generation compared to CPU.
Requirements
NVIDIA GPU (GTX 1060 or newer recommended)
CUDA drivers installed
For Docker: NVIDIA Container Runtime
Verify GPU Setup
GPU Performance Tips
Pre-load checkpoints to reduce first-generation latency:
load_checkpoint("default") # Pre-loads Animagine XL 4.0Monitor GPU usage during generation:
watch -n 1 nvidia-smiOptimize memory for large models:
# Set in environment export PYTORCH_CUDA_ALLOC_CONF="max_split_size_mb:512"
See GPU_SETUP.md for detailed GPU configuration.
Docker Configuration
Three Docker Compose configurations are available:
File | Description | Use Case |
| GPU-enabled (default) | Production with NVIDIA GPU |
| Advanced GPU settings | Multi-GPU, profiling |
| CPU-only fallback | Development, no GPU |
Switching Configurations
Custom Port
Edit docker-compose.yml:
Resource Limits
See DOCKER.md for comprehensive Docker documentation.
Model Management
Adding Checkpoints
Place .safetensors or .ckpt files in ./checkpoints/:
Adding LoRAs
Place LoRA files in ./loras/:
Verifying Models
Environment Variables
Variable | Description | Default |
| GPU device ID(s) |
|
| Enable cuDNN auto-tuner |
|
| Memory allocation config |
|
| Hugging Face cache directory |
|
| Disable HF telemetry |
|
Setting Variables
Local:
Docker (in docker-compose.yml):
Performance Optimization
Recommended Settings by GPU
GPU | VRAM | Recommended Steps | Batch Size |
RTX 3060 | 12GB | 28 | 1 |
RTX 3080 | 10GB | 28 | 1 |
RTX 3090 | 24GB | 28-50 | 1-2 |
RTX 4090 | 24GB | 28-50 | 2-4 |
A100 | 40GB+ | 50+ | 4+ |
Speed vs Quality Trade-offs
Setting | Speed | Quality |
| Fast | Good |
| Balanced | Great |
| Slow | Excellent |
Using LCM LoRA for Speed
AI Agent Resources
This repository includes comprehensive documentation optimized for AI agents and automated workflows.
Documentation Structure
Directory | Purpose | Key Files |
| Model behavior specifications |
|
| Interface contracts and schemas |
|
| Quality guidelines and strategies |
|
| Implementation guides |
|
For AI Agent Developers
These resources are designed for:
Prompt Engineering: Detailed taxonomy and rules for Animagine XL 4.0 prompts
Automated Pipelines: Structured contracts for integrating with CI/CD or batch processing
Quality Assurance: Evaluation criteria and negative prompt strategies
MCP Integration: Interface specifications for building MCP-compatible clients
Quick Links
Using with AI Coding Assistants
When using AI coding assistants (Claude, Cursor, Copilot, etc.), you can reference these docs:
Repository Layout
Contributors Guide
We welcome contributions! Here's how to get started.
Development Setup
Step 1: Fork and clone
Step 2: Create development environment
Step 3: Install with development dependencies
Step 4: Create a feature branch
Code Style
We follow these conventions:
Python Style
Formatter:
blackwith default settingsLinter:
rufffor fast lintingType hints: Required for all public functions
Docstrings: Google style for all public APIs
Run Formatting
Pre-commit (Recommended)
Pull Request Process
1. Before Submitting
Code follows the style guide
Tests pass locally
Documentation updated (if applicable)
Commit messages are clear and descriptive
2. PR Template
Use this template for your PR description:
3. Review Process
Submit PR to
mainbranchAutomated checks run (linting, tests)
Maintainer reviews code
Address feedback if any
PR merged after approval
4. Commit Message Format
Types: feat, fix, docs, style, refactor, test, chore
Examples:
Testing Guidelines
Running Tests
Writing Tests
Test Categories
Category | Description | Location |
Unit | Individual functions |
|
Integration | Component interaction |
|
E2E | Full workflow |
|
Areas for Contribution
Looking for something to work on? Here are some areas:
Good First Issues
Documentation improvements
Adding test coverage
Fixing typos or clarifying comments
Feature Ideas
Additional prompt optimization strategies
New LoRA management features
Performance benchmarking tools
Web UI frontend
Documentation
Tutorials for specific use cases
Video walkthroughs
Translated documentation
Support
Getting Help
Check existing issues: Search GitHub Issues
Read documentation: Check
DOCKER.md,GPU_SETUP.md, and this READMEOpen new issue: Include:
Description of the problem
Steps to reproduce
Expected vs actual behavior
System info (OS, GPU, Python version)
Relevant logs (omit sensitive content)
Community
GitHub Discussions for questions
Issues for bugs and feature requests
License
This project is licensed under the terms specified in LICENSE.
Acknowledgments
Animagine XL by Cagliostro Lab
FastMCP for the MCP framework
Diffusers by Hugging Face
All contributors and community members