MCP-compliant image augmentation server using Albumentations
Project description
Albumentations-MCP
๐ Beta v0.1 - Production Ready - Core functionality complete, published on PyPI
Natural Language Image Augmentation via MCP Protocol
Transform images using plain English with this MCP-compliant server built on Albumentations. Designed for computer vision teams who need quick, reliable image transformations without repetitive coding.
Example: "add blur and rotate 15 degrees" โ Applies GaussianBlur + Rotate transforms automatically
๐ฏ Quick Start
# Install from PyPI (coming soon)
pip install albumentations-mcp
# Or install from source
git clone https://github.com/ramsi-k/albumentations-mcp
cd albumentations-mcp
uv sync
# Run as MCP server
uvx albumentations-mcp
# Or test with CLI demo
uv run python -m albumentations_mcp.demo --image examples/cat.jpg --prompt "add blur" --seed 42
๐ง MCP Client Setup
Claude Desktop
Add to your ~/.claude_desktop_config.json:
{
"mcpServers": {
"albumentations": {
"command": "uvx",
"args": ["albumentations-mcp"],
"env": {
"MCP_LOG_LEVEL": "INFO",
"OUTPUT_DIR": "./outputs",
"ENABLE_VISION_VERIFICATION": "true",
"DEFAULT_SEED": "42"
}
}
}
}
Kiro IDE
Add to your .kiro/settings/mcp.json:
{
"mcpServers": {
"albumentations": {
"command": "uvx",
"args": ["albumentations-mcp"],
"env": {
"MCP_LOG_LEVEL": "INFO",
"OUTPUT_DIR": "./outputs",
"ENABLE_VISION_VERIFICATION": "true",
"DEFAULT_SEED": "42"
},
"disabled": false,
"autoApprove": ["augment_image", "list_available_transforms"]
}
}
}
๐ ๏ธ Available MCP Tools
augment_image
Apply image augmentations based on natural language prompt or preset.
# Example usage in MCP client
augment_image(
image_b64="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...",
prompt="add blur and increase contrast",
seed=42 # Optional for reproducible results
)
Parameters:
image_b64(str): Base64-encoded image dataprompt(str): Natural language description of desired augmentationsseed(int, optional): Random seed for reproducible resultspreset(str, optional): Use preset instead of prompt ("segmentation", "portrait", "lowlight")
Returns: Base64-encoded augmented image
list_available_transforms
Get list of supported transforms with descriptions and parameters.
# Returns comprehensive list of available transforms
list_available_transforms()
Returns: List of transform objects with names, descriptions, and parameter ranges
validate_prompt
Parse and validate a natural language prompt without applying transforms.
# Test what transforms would be applied
validate_prompt(prompt="add blur and rotate 15 degrees")
Parameters:
prompt(str): Natural language prompt to validate
Returns: Parsed transform pipeline with parameters and warnings
set_default_seed
Set default seed for consistent reproducibility across all augment_image calls.
# Set default seed for all future operations
set_default_seed(seed=42)
# Clear default seed
set_default_seed(seed=None)
Parameters:
seed(int, optional): Default seed value (0 to 4294967295), or None to clear
Returns: Dictionary with operation status and current default seed
list_available_presets
List all available preset configurations.
# Get all available presets
list_available_presets()
Returns: Dictionary containing available presets and their descriptions
get_pipeline_status
Get current pipeline status and hook system information.
# Check pipeline health and configuration
get_pipeline_status()
Returns: Pipeline status, registered hooks, and system information
Usage Examples
Basic Image Augmentation
# Simple blur and rotation
result = augment_image(
image_b64=your_image_b64,
prompt="add blur and rotate 15 degrees"
)
# Multiple transforms
result = augment_image(
image_b64=your_image_b64,
prompt="increase brightness, add noise, and flip horizontally"
)
# Reproducible results
result = augment_image(
image_b64=your_image_b64,
prompt="add blur and rotate",
seed=42 # Same seed = same result
)
Using Presets
# Optimized for segmentation tasks
result = augment_image(
image_b64=your_image_b64,
preset="segmentation"
)
# Portrait photography enhancements
result = augment_image(
image_b64=your_image_b64,
preset="portrait"
)
# Low-light image improvements
result = augment_image(
image_b64=your_image_b64,
preset="lowlight"
)
Natural Language Parsing
The parser understands various ways to describe transforms:
- Blur: "add blur", "make blurry", "gaussian blur"
- Rotation: "rotate 15 degrees", "turn clockwise", "rotate left"
- Brightness: "increase brightness", "make brighter", "brighten"
- Contrast: "add contrast", "increase contrast", "make more contrasty"
- Noise: "add noise", "make noisy", "gaussian noise"
- Flipping: "flip horizontally", "mirror", "flip vertical"
- Cropping: "crop center", "random crop", "crop 224x224"
โ Features
Core Functionality
- โ 4 MCP Tools: Complete API for image augmentation
- โ Natural Language Parser: Converts prompts to Albumentations transforms
- โ Reproducible Results: Seeding support for consistent outputs
- โ Preset Pipelines: Pre-configured transforms for common use cases
- โ CLI Demo: Test functionality without MCP client
Advanced Features
- โ 7-Stage Hook System: Complete processing pipeline with all hooks active
- โ Visual Verification: AI-powered result validation
- โ Error Recovery: Graceful handling of edge cases
- โ Comprehensive Testing: 90%+ test coverage
- โ Production Logging: Structured JSON logs with session tracking
Quality & Reliability
- โ Type Safety: Full type hints with mypy validation
- โ Code Quality: Black formatting, Ruff linting
- โ Documentation: Comprehensive API docs and examples
- โ PyPI Ready: Proper package structure for distribution
๐๏ธ Architecture
MCP Protocol Compliance
- Standard JSON-RPC: Full MCP protocol implementation
- Tool Discovery: Automatic schema generation and validation
- Error Handling: Proper status codes and error messages
- Streaming Support: Efficient handling of large images
Complete Hook System
All 7 implemented hooks are active and run automatically in sequence:
- pre_mcp: Input sanitization and preprocessing โ
- post_mcp: JSON spec logging and validation โ
- pre_transform: Image and configuration validation โ
- post_transform: Metadata generation and attachment โ
- post_transform_verify: AI-powered visual verification โ
- pre_save: File management and versioning โ
- post_save: Cleanup and completion logging โ
Coming in v0.2:
- post_transform_classify: Classification consistency checking (8th hook)
- Individual hook toggles via environment variables
- Custom hook development framework
Production-Ready Design
- Async Processing: Non-blocking operations with proper resource management
- Memory Management: Automatic cleanup of large image arrays
- Session Tracking: Unique session IDs for request correlation
- Structured Logging: JSON logs with contextual information
๐ง Development Setup
Prerequisites
- Python 3.9+
- uv package manager
Installation
# Clone repository
git clone https://github.com/ramsi-k/albumentations-mcp
cd albumentations-mcp
# Install dependencies
uv sync
# Install pre-commit hooks
uv run pre-commit install
# Run tests
uv run pytest
# Run MCP server
uv run python -m albumentations_mcp
Development Commands
# Format code
uv run black src/ tests/
# Lint code
uv run ruff check src/ tests/ --fix
# Type checking
uv run mypy src/
# Run all quality checks
uv run pre-commit run --all-files
# Run tests with coverage
uv run pytest --cov=src --cov-report=html
# Build package
uv build
Testing the MCP Server
# Test with CLI demo
uv run python -m albumentations_mcp.demo --image examples/cat.jpg --prompt "add blur"
# Test MCP protocol (requires MCP client)
uvx albumentations-mcp
# Run integration tests
uv run python scripts/test_mcp_integration.py
๐ Use Cases
Perfect for computer vision teams working on:
- Data preprocessing pipelines - Quick augmentation without boilerplate
- ML model training - Reproducible transforms with seeding support
- Image analysis workflows - Natural language interface for non-technical users
- Rapid prototyping - Test augmentation ideas without writing code
๐ Project Structure
src/albumentations_mcp/
โโโ server.py # FastMCP server with 4 working tools
โโโ parser.py # Natural language โ Albumentations transforms
โโโ pipeline.py # Hook-integrated processing pipeline
โโโ processor.py # Image processing engine
โโโ verification.py # AI-powered visual verification
โโโ hooks/ # Complete 7-stage hook system
โ โโโ pre_mcp.py # Input sanitization โ
โ โโโ post_mcp.py # JSON spec logging โ
โ โโโ pre_transform.py # Image validation โ
โ โโโ post_transform.py # Metadata generation โ
โ โโโ post_transform_verify.py # Visual verification โ
โ โโโ pre_save.py # File management โ
โ โโโ post_save.py # Cleanup and completion โ
โโโ image_utils.py # Base64 โ PIL conversion utilities
tests/ # Comprehensive test suite
โโโ test_image_utils.py # Image handling tests
โโโ test_parser.py # Natural language parsing tests
โโโ test_hooks_integration.py # Hook system tests
โโโ test_mcp_protocol_compliance.py # MCP protocol tests
๐ Code Quality & Best Practices
- Type Safety: Full type hints with mypy validation
- Code Quality: Black formatting, Ruff linting, pre-commit hooks
- Testing: 90%+ test coverage with pytest and async testing
- Documentation: Google-style docstrings and comprehensive specs
- Error Handling: Graceful degradation with detailed error messages
- Performance: Async/await patterns with efficient resource management
๐ Troubleshooting
Common Issues
MCP Server Not Starting
# Check if uv is installed
uv --version
# Ensure dependencies are installed
uv sync
# Run with debug logging
MCP_LOG_LEVEL=DEBUG uvx albumentations-mcp
Image Processing Errors
- Ensure image is valid Base64-encoded data
- Check image format is supported (JPEG, PNG, WebP, etc.)
- Verify image size is reasonable (< 10MB recommended)
Natural Language Parsing Issues
- Use simple, clear descriptions: "add blur" vs "make it blurry"
- Check available transforms with
list_available_transforms - Validate prompts with
validate_promptbefore processing
File Saving Issues
- Hook system creates session directories but file saving may fail
- MCP tools return base64 images correctly (core functionality works)
- CLI demo shows file paths but actual file creation is in development
MCP Client Integration
- Verify MCP client supports stdio transport
- Check configuration file syntax (JSON formatting)
- Ensure
uvxcommand is available in PATH
Getting Help
- Check the Issues page
- Run with debug logging:
MCP_LOG_LEVEL=DEBUG - Test with CLI demo to isolate MCP vs processing issues
- Review the comprehensive test suite for usage examples
๐ค Contributing
Contributions welcome! This project follows standard Python development practices:
- Code Style: Black formatting, Ruff linting
- Type Safety: Full type hints with mypy validation
- Testing: Pytest with 90%+ coverage requirement
- Documentation: Google-style docstrings
Areas of particular interest:
- Additional transform mappings for natural language parser
- New preset pipelines for specific use cases
- Performance optimizations for large images
- Additional MCP client integrations
๐ Contact & Support
Ramsi Kalia - ramsi.kalia@gmail.com
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ง Direct Contact: ramsi.kalia@gmail.com
This project demonstrates production-ready system design with clean architecture, comprehensive testing, and thoughtful user experience. Built for the Kiro Hackathon.
๐ Detailed Specifications
For technical deep-dive and implementation details:
๐ Requirements - User stories and acceptance criteria
๐๏ธ Design - System architecture and component interfaces
๐ Tasks - Development roadmap and implementation plan
๐งช Testing - Comprehensive test strategy
License: MIT
Status: Beta v0.1 - Core features complete, advanced features in development
Developed for the Kiro Hackathon
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 albumentations_mcp-0.1.0b2.tar.gz.
File metadata
- Download URL: albumentations_mcp-0.1.0b2.tar.gz
- Upload date:
- Size: 229.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b0078629e5db83f7bf5a25009399203c8744007fed3ae26300b0f5971235a7
|
|
| MD5 |
a9bb2dcca2117c8729ecabba5be5779f
|
|
| BLAKE2b-256 |
529182c1ab670cb0f5228b85e33804529fbb8e625d7e20af32e71d4f74e835ab
|
File details
Details for the file albumentations_mcp-0.1.0b2-py3-none-any.whl.
File metadata
- Download URL: albumentations_mcp-0.1.0b2-py3-none-any.whl
- Upload date:
- Size: 88.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21be74ea930d653bb3f40d111417c514100c548e22e914790908d748fcf7c8e
|
|
| MD5 |
63ba71a3dc919ef0eecad6ee4e0fb364
|
|
| BLAKE2b-256 |
158b9f20c580f009c802375fef8bc960480b7f889d6cee00220dbde220671b28
|