MCP Server for GIMP - AI Assistant for Image Editing
Project description
GIMP MCP Server
A comprehensive Model Context Protocol (MCP) server implementation for GIMP 3.0+, enabling AI assistants to perform sophisticated image editing operations through GIMP's GObject Introspection bindings.
๐ Features
Core Capabilities
- ๐จ Document Management: Create, open, save, and export GIMP documents
- ๐๏ธ Layer Operations: Advanced layer management with opacity, blend modes, and transformations
- โ๏ธ Drawing Tools: Brush strokes, shapes, and artistic drawing operations
- ๐ฒ Selection Tools: Rectangular, elliptical, and advanced selection management
- ๐จ Color Management: Color sampling, palette operations, and color space handling
- ๐ญ Filter Operations: Image filters and effects processing
- ๐ Hybrid Mode Support: Seamless operation in both GUI and headless environments
- ๐ก Real-time Resources: Live document state and system status monitoring
Advanced Features
- โก High Performance: Optimized for both single operations and batch processing
- ๐ก๏ธ Robust Error Handling: Comprehensive error management and recovery
- ๐ง Extensible Architecture: Modular design for easy feature additions
- ๐ Resource Monitoring: Real-time document and system state tracking
- ๐ Comprehensive Logging: Detailed operation tracking and debugging
๐ Requirements
System Requirements
- Operating System: Linux (Ubuntu 20.04+), Windows 10+, macOS 11+
- Python: 3.9+ (for GIMP 3.0 compatibility)
- GIMP: 3.0+ with Python support enabled
- Memory: 4GB RAM minimum, 8GB recommended for large images
- Storage: 1GB free space for installation
Dependencies
- GTK4: GTK4 development libraries
- GObject: GObject Introspection libraries
- PyGObject: Python GObject bindings
- FastMCP: MCP server framework
๐ Installation
Quick Install (Recommended)
# Install from PyPI (when available)
pip install gimp-mcp-server
# Or install from source
pip install git+https://github.com/gimp-mcp/gimp-mcp-server.git
Detailed Installation
For detailed installation instructions including platform-specific setup, see our Installation Guide.
Linux (Ubuntu/Debian)
# Install system dependencies
sudo apt update
sudo apt install gimp-3.0 python3-dev python3-pip
sudo apt install libgtk-4-dev libgirepository1.0-dev
# Install Python dependencies
pip3 install PyGObject
pip3 install gimp-mcp-server
macOS (Homebrew)
# Install dependencies
brew install gimp python@3.9 gtk4 gobject-introspection
pip3 install PyGObject gimp-mcp-server
Windows
See Windows Installation Guide for detailed setup instructions.
๐ฏ Quick Start
1. Start the Server
# Basic startup
gimp-mcp-server
# With custom configuration
gimp-mcp-server --port 3000 --host localhost --debug
2. Connect with Claude Desktop
Add to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"gimp": {
"command": "gimp-mcp-server",
"args": []
}
}
}
3. Test the Connection
In Claude Desktop, try:
"Create a new 1920x1080 document and add a red circle in the center"
Claude will automatically:
- Create the document using
create_document - Draw the circle using
draw_ellipse - Set appropriate colors and layers
๐๏ธ Architecture
The GIMP MCP Server follows a modern, modular architecture:
src/gimp_mcp/
โโโ server.py # FastMCP server implementation
โโโ gimp_api.py # GIMP GI bindings wrapper
โโโ mode_manager.py # GUI/Headless mode detection
โโโ tools/ # MCP tool implementations
โ โโโ document_tools.py # Document management
โ โโโ layer_tools.py # Layer operations
โ โโโ drawing_tools.py # Drawing operations
โ โโโ selection_tools.py # Selection management
โ โโโ color_tools.py # Color operations
โ โโโ filter_tools.py # Filter operations
โโโ resources/ # MCP resource providers
โ โโโ providers.py # Real-time state resources
โโโ utils/ # Utility modules
โโโ logging.py # Structured logging
โโโ errors.py # Error handling
โโโ gi_helpers.py # GObject helpers
โโโ image_utils.py # Image processing
๐ ๏ธ Available Tools
Document Management (6 tools)
| Tool | Description | Key Parameters |
|---|---|---|
create_document |
Create new documents | width, height, resolution, color_mode |
open_document |
Open existing files | file_path |
save_document |
Save documents | document_id, file_path |
export_document |
Export to formats | file_path, format, options |
get_document_info |
Get document details | document_id |
list_documents |
List open documents | None |
Layer Operations (8 tools)
| Tool | Description | Key Parameters |
|---|---|---|
create_layer |
Create new layers | name, layer_type, opacity, blend_mode |
get_layer_info |
Get layer details | layer_id, document_id |
set_layer_opacity |
Adjust opacity | layer_id, opacity |
set_layer_blend_mode |
Change blend mode | layer_id, blend_mode |
set_layer_visibility |
Toggle visibility | layer_id, visible |
duplicate_layer |
Duplicate layers | layer_id, new_name |
delete_layer |
Remove layers | layer_id |
move_layer |
Reorder layers | layer_id, new_position |
Drawing Tools (4 tools)
| Tool | Description | Key Parameters |
|---|---|---|
apply_brush_stroke |
Paint with brushes | points, brush_name, size, color |
draw_rectangle |
Draw rectangles | x, y, width, height, fill_color |
draw_ellipse |
Draw ellipses | center_x, center_y, radius_x, radius_y |
bucket_fill |
Fill areas | x, y, color, threshold |
Selection Tools (4 tools)
| Tool | Description | Key Parameters |
|---|---|---|
create_rectangular_selection |
Rectangle selections | x, y, width, height |
create_elliptical_selection |
Ellipse selections | center_x, center_y, radius_x, radius_y |
modify_selection |
Modify selections | operation, value |
clear_selection |
Clear selections | None |
Color Management (4 tools)
| Tool | Description | Key Parameters |
|---|---|---|
set_foreground_color |
Set foreground | color |
set_background_color |
Set background | color |
sample_color |
Sample from image | x, y, sample_merged |
get_active_palette |
Get color palette | None |
Filter Operations (3 tools)
| Tool | Description | Key Parameters |
|---|---|---|
apply_blur |
Blur effects | radius, method |
apply_sharpen |
Sharpen effects | amount, threshold |
adjust_brightness_contrast |
Adjust levels | brightness, contrast |
๐ก Available Resources
Real-time State Monitoring
document://current- Current document statedocument://list- List of open documentsdocument://metadata- Document metadatasystem://status- System and server statussystem://capabilities- Server capabilitiessystem://health- System health informationpalettes://active- Active color palettebrushes://list- Available brush presetstools://current- Current tool state
๐ก Example Usage
Basic Image Creation
// Create a new document
const doc = await mcp.callTool("create_document", {
width: 1024,
height: 768,
name: "My Artwork"
});
// Create a layer for shapes
const layer = await mcp.callTool("create_layer", {
name: "Shapes",
layer_type: "RGB"
});
// Draw a blue rectangle
await mcp.callTool("draw_rectangle", {
x: 100,
y: 100,
width: 300,
height: 200,
fill_color: "#3498DB"
});
// Add a red circle
await mcp.callTool("draw_ellipse", {
center_x: 250,
center_y: 200,
radius_x: 80,
radius_y: 80,
fill_color: "#E74C3C"
});
// Save the document
await mcp.callTool("save_document", {
file_path: "/path/to/my-artwork.xcf"
});
// Export as PNG
await mcp.callTool("export_document", {
file_path: "/path/to/my-artwork.png",
options: { optimize: true }
});
Batch Processing
// Process multiple images
const images = ["image1.jpg", "image2.jpg", "image3.jpg"];
for (const imagePath of images) {
// Open image
const doc = await mcp.callTool("open_document", {
file_path: imagePath
});
// Apply blur filter
await mcp.callTool("apply_blur", {
radius: 2.0,
method: "gaussian"
});
// Adjust brightness
await mcp.callTool("adjust_brightness_contrast", {
brightness: 10,
contrast: 5
});
// Export processed version
await mcp.callTool("export_document", {
file_path: imagePath.replace(".jpg", "_processed.png")
});
}
๐งช Testing
Run Tests
# Install test dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run with coverage
pytest --cov=gimp_mcp --cov-report=html
# Run specific test categories
pytest -m unit # Unit tests only
pytest -m integration # Integration tests only
pytest -m "not slow" # Exclude slow tests
Test Server Connection
# Quick connection test
gimp-mcp-server --test-connection
# System requirements check
gimp-mcp-server --system-check
# Run in debug mode
GIMP_MCP_DEBUG=1 gimp-mcp-server --debug
๐ง Configuration
Environment Variables
export GIMP_MCP_DEBUG=1 # Enable debug logging
export GIMP_MCP_HOST=localhost # Server host
export GIMP_MCP_PORT=3000 # Server port
export GIMP_MCP_MODE=hybrid # Mode: gui, headless, or hybrid
export GIMP_MCP_LOG_LEVEL=INFO # Logging level
Advanced Configuration
# Custom GIMP path
export GIMP_PATH=/custom/path/to/gimp
# Memory settings
export GIMP_CACHE_SIZE=4096 # 4GB cache
export GIMP_TILE_CACHE_SIZE=2048 # 2GB tiles
# Performance tuning
export GIMP_NUM_PROCESSORS=4 # CPU cores to use
export GIMP_USE_OPENCL=yes # GPU acceleration
๐ Documentation
Comprehensive Docs
- User Guide - Installation, setup, and basic usage
- API Reference - Complete tool and resource documentation
- Tutorials - Step-by-step examples and workflows
- Integration Guide - MCP client integration
- Troubleshooting - Common issues and solutions
Quick Reference
- Command Reference - Quick tool reference
- Error Codes - Error handling guide
- Parameter Reference - Complete parameter guide
Developer Resources
- Development Guide - Contributing and development setup
- Architecture Guide - Technical deep-dive
- Extension Guide - Adding new features
- Testing Guide - Testing procedures
๐จ Troubleshooting
Common Issues
GIMP Connection Failed
# Check GIMP installation
which gimp && gimp --version
# Test GIMP Python support
gimp --batch-interpreter=python-fu-eval --batch='print("Python OK")' --batch='quit()'
# Install missing dependencies
pip install PyGObject
Module Import Errors
# Install system dependencies (Ubuntu)
sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0
# Install system dependencies (macOS)
brew install pygobject3 gtk+3
Permission Errors
# Linux: Add user to video group
sudo usermod -a -G video $USER
# Restart session after group changes
For detailed troubleshooting, see our Troubleshooting Guide.
๐ Performance
Optimization Tips
- Use appropriate image sizes - Larger images consume more memory and processing time
- Batch related operations - Group similar operations together
- Monitor system resources - Close unused documents to free memory
- Use headless mode - For batch processing without GUI overhead
- Enable GPU acceleration - Set
GIMP_USE_OPENCL=yesfor compatible operations
Benchmarks
- Document creation: ~50ms for standard sizes (1920x1080)
- Layer operations: ~10-30ms depending on complexity
- Drawing operations: ~20-100ms depending on brush size and stroke length
- Filter operations: ~100ms-5s depending on filter type and image size
๐ค Contributing
We welcome contributions! Please see our Development Guide for details.
Quick Contribution Steps
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-tool - Make your changes with tests
- Run the test suite:
pytest - Submit a pull request
Development Setup
# Clone and setup
git clone https://github.com/gimp-mcp/gimp-mcp-server.git
cd gimp-mcp-server
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
๐ Project Status
Current Status
- โ Core Implementation: Complete with all major tools
- โ Documentation: Comprehensive user and developer docs
- โ Testing: Full test suite with unit and integration tests
- โ Error Handling: Robust error management and recovery
- โ Performance: Optimized for production use
- ๐ PyPI Release: Coming soon
- ๐ GUI Integration: Enhanced GUI mode features
Roadmap
- v1.1: Enhanced filter operations and batch processing
- v1.2: Plugin system for custom tools
- v1.3: Advanced selection tools and path operations
- v2.0: GIMP 3.1+ support and new features
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- GIMP Development Team - For excellent GObject Introspection bindings
- FastMCP Framework - For robust MCP server implementation
- Model Context Protocol - For standardized AI tool integration
- Community Contributors - For testing, feedback, and contributions
๐ Support & Community
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ Documentation: Complete Docs
- ๐ Releases: Release Notes
Made with โค๏ธ for the GIMP and AI community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gimp_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: gimp_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 227.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d55e4630af6104994b8c698a336f74649b9468a33b2d7d57142250d6891f270
|
|
| MD5 |
8d052ecbf49d06bf61b04b50fe2b0146
|
|
| BLAKE2b-256 |
20dd5bbe580bce9f29fb526d17d07dea9300227f038d8971cd2fc9db067f525f
|
File details
Details for the file gimp_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gimp_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cab5d7aaec343d394b2b1b45302b08bf481261aa806bf59207b938764e2bbf1c
|
|
| MD5 |
67903f32301f7e31f6956386555d92fb
|
|
| BLAKE2b-256 |
ff3dbe4a1c3f37ad735a3ceeb3dca7a3f465ea502b282b028365d252cf39d212
|