Rembg MCP Server
An MCP (Model Context Protocol) server for the rembg background removal library. Remove image backgrounds using AI models through Claude Code, Claude Desktop, Cursor, and other MCP-compatible tools.
🎯 Features
🖼️ Image Processing: Remove backgrounds from single images or batch process folders
🤖 Multiple AI Models: u2net, birefnet, isnet, sam, and more specialized models
⚡ Performance Optimized: Model session reuse for efficient batch processing
🎨 Advanced Options: Alpha matting, mask-only output, custom backgrounds
🌍 Cross-Platform: Support for Windows, macOS, and Linux
🔧 Easy Integration: Works with Claude Desktop, Claude Code CLI, Cursor IDE
📦 Quick Start
🚀 One-Click Installation
Linux/macOS
Windows
The setup scripts will automatically:
Check Python 3.10+ requirement
Create virtual environment
Install all dependencies
Configure MCP server
Test the installation
Guide you through AI model downloads
🔧 Manual Installation
If you prefer manual installation or need custom configuration:
Create virtual environment:
Install dependencies:
Test installation:
Download AI models:
For GPU support:
🔧 MCP Configuration
Claude Desktop Setup
Find your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
Linux:
~/.config/Claude/claude_desktop_config.json
Add the rembg server configuration:
Replace with your actual project path
Restart Claude Desktop
Testing Your Setup
After configuration, test your MCP server:
Start the server manually:
Verify MCP connection in Claude Desktop:
Look for the rembg tools in your Claude conversation
Try a simple command: "List available MCP tools"
Test with a sample image:
Ask Claude: "Use rembg-i to remove the background from test.jpg"
The server will process your request and return results
Claude Code CLI Setup
Add to your Claude Code settings:
Cursor IDE Setup
Add to your Cursor settings or workspace .cursor/settings.json
:
Windows Configuration
For Windows users, use start_server.bat
instead:
🚀 How to Use
Once configured, you can use the rembg tools directly in your MCP-compatible application:
Basic Usage Examples
Single Image Processing:
Batch Processing:
Advanced Processing:
🛠️ Available MCP Tools
rembg-i - Single Image Background Removal
Removes background from a single image file with high precision.
Required Parameters:
input_path
: Path to the source image fileoutput_path
: Where to save the processed image
Optional Parameters:
model
: AI model to use (default: "u2net")alpha_matting
: Improve edge quality (default: false)only_mask
: Output black/white mask only (default: false)
Supported formats: JPG, PNG, BMP, TIFF, WebP
rembg-p - Batch Folder Processing
Processes all images in a folder automatically.
Required Parameters:
input_folder
: Source folder containing imagesoutput_folder
: Destination folder for processed images
Optional Parameters:
model
: AI model to use (default: "u2net")alpha_matting
: Improve edge quality (default: false)only_mask
: Output masks only (default: false)file_extensions
: File types to process (default: common image formats)
Features:
Automatically finds all supported images
Preserves original filenames with
.out.png
suffixDetailed progress reporting
Error handling for individual files
🤖 Supported AI Models
Model | Use Case | Size | Quality |
| General purpose (default) | Medium | Good |
| Lightweight version | Small | Good |
| Human subjects | Medium | Good |
| Clothing segmentation | Medium | Good |
| Lightweight general | Small | Good |
| High quality general | Large | Excellent |
| Anime characters | Large | Excellent |
| High accuracy general | Large | Excellent |
| Portrait photos | Large | Excellent |
| Massive dataset trained | X-Large | Best |
| Segment Anything (prompt-based) | Large | Variable |
🎯 Model Recommendations
For beginners: Start with u2net
(default) - good balance of speed and quality
For best quality: Use birefnet-general
or birefnet-massive
For portraits: Use birefnet-portrait
- specialized for human subjects
For anime/cartoons: Use isnet-anime
- optimized for animated content
For speed: Use u2netp
or silueta
- faster processing for batch jobs
📥 Downloading Models
Models are downloaded automatically when first used, but you can pre-download them:
Models are cached in ~/.u2net/
and only need to be downloaded once.
🔧 Configuration
Environment Variables
REMBG_HOME
: Model storage directory (default:~/.u2net
)OMP_NUM_THREADS
: Number of CPU threads for processing (default: 4)MODEL_CHECKSUM_DISABLED
: Skip model checksum verification
Advanced Options
Alpha Matting: Improves edge quality but increases processing time
Mask Only: Returns black/white mask instead of transparent cutout
Custom Background Colors: Replace transparent areas with solid colors
Batch Processing: Automatically reuses model sessions for efficiency
📁 Project Structure
🚨 Troubleshooting
Common Issues
MCP Server Not Found
Verify the
command
path in your MCP configurationEnsure the script is executable:
chmod +x start_server.sh
Check that the virtual environment exists:
ls rembg/
Python Version Issues
Model Download Problems
Memory or Performance Issues
Installation Problems
Getting Help
Run
python validate_setup.py
for detailed diagnosticsCheck server logs when starting manually
Ensure your MCP client supports the latest protocol version
📚 Additional Resources
🤝 Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature
)Commit your changes (
git commit -m 'Add amazing feature'
)Push to the branch (
git push origin feature/amazing-feature
)Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
danielgatis/rembg - The excellent background removal library
Anthropic - For the MCP protocol and Claude
The open source community for the various AI models
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables AI-powered background removal from images using multiple specialized models including u2net, birefnet, and isnet. Supports both single image processing and batch folder operations with advanced options like alpha matting and mask-only output.