remove-background
Click on "Deploy 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., "@remove-background remove background from product_photo.jpg"
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.
MCP Remove Background Server
A Model Context Protocol (MCP) server for removing backgrounds from images using AI-powered segmentation models.
Features
Background Removal: Remove backgrounds from images using AI-powered segmentation
Multiple model options optimized for different image types
Outputs PNG with full alpha transparency
Fast flood-fill algorithm for simple backgrounds (optional)
Model Catalog: Access comprehensive information about all available background removal models
Related MCP server: Image Toolkit MCP Server
Supported Models
Model | Size | Best For | Quality |
| 176MB | General purpose (default) | Good |
| 4MB | Lightweight/mobile | Moderate |
| 43MB | General, smaller footprint | Good |
| 176MB | General, newer | Very Good |
| 176MB | Anime/illustrations | Excellent for art |
| 400MB | Best quality | Excellent |
| 100MB | Balanced | Very Good |
| 400MB | Segment Anything | Excellent |
Installation
Option 1: Install with pipx (Recommended for CLI usage)
# Install directly from the repository
pipx install git+https://github.com/your-username/MCP-remove-background.git
# Or install from local directory
cd MCP-remove-background
pipx install .
# Run the server
mcp-remove-backgroundOption 2: Install with Poetry (Recommended for development)
# Clone the repository
git clone <repository-url>
cd MCP-remove-background
# Install dependencies with Poetry
just setup
# Run the server
poetry run mcp-remove-background
# Or
poetry run python -m MCP_remove_background.serverOption 3: Install with pip
# Install from the repository
pip install git+https://github.com/your-username/MCP-remove-background.git
# Or install from local directory
pip install .
# Run the server
mcp-remove-backgroundUsage
Running the Server
# If installed with pipx or pip
mcp-remove-background
# If using Poetry (development)
poetry run mcp-remove-background
# Alternative: run as Python module
poetry run python -m MCP_remove_background.server
# With FastMCP CLI (more options)
poetry run fastmcp run MCP_remove_background/server.py --transport http --port 8000CLI Options
When using the fastmcp run command, you have additional options:
Option | Description |
| Transport protocol: |
| Host to bind to (default: 127.0.0.1) |
| Port for HTTP/SSE transport (default: 8000) |
| Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL |
| Don't show the server banner |
MCP Client Configuration
To use this MCP server with an AI agent, add the following configuration to your MCP client.
Claude Desktop (pipx installation)
If you installed with pipx, add to your Claude Desktop configuration file (~/.config/claude/claude_desktop_config.json on Linux, ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"remove-background": {
"command": "mcp-remove-background"
}
}
}Claude Desktop (Poetry installation)
If you're using Poetry for development:
{
"mcpServers": {
"remove-background": {
"command": "poetry",
"args": ["run", "mcp-remove-background"],
"cwd": "/path/to/MCP-remove-background"
}
}
}Cline / Roo Code
Add to your VS Code settings or Cline MCP configuration:
{
"mcpServers": {
"remove-background": {
"command": "mcp-remove-background"
}
}
}Generic MCP Client (Copy-Paste Ready)
For pipx/pip installation:
{
"remove-background": {
"command": "mcp-remove-background"
}
}For Poetry installation:
{
"remove-background": {
"command": "poetry",
"args": ["run", "mcp-remove-background"],
"cwd": "/path/to/MCP-remove-background"
}
}Configuration Options:
Field | Description |
| The command to run ( |
| Command arguments to start the MCP server |
| Working directory - set to your MCP-remove-background installation path |
Important: Replace /path/to/MCP-remove-background with the actual path to your installation.
Tools
remove_background
Remove the background from an image, replacing it with transparency.
Parameters:
image_path(required): Path to the image file to processoutput_path(optional): Path for the output PNG file (auto-generated if not specified)model(optional): Background removal model (default: "u2net")alpha_matting(optional): Enable alpha matting for smoother edges (default: false)try_floodfill_first(optional): Try fast flood-fill before ML (default: true)
Returns:
success: Whether background removal succeededinput_path: Path to the input fileoutput_path: Path to the output PNG file with transparencyfile_size_bytes: Size of the output file in bytesmethod_used: "floodfill" or model namemodel_used: The model that was configurederror: Error message if removal failed
Example:
result = await remove_background(
image_path="/path/to/image.png",
model="isnet-anime"
)
if result["success"]:
print(f"Transparent image saved to: {result['output_path']}")list_background_models
List all available background removal models with their descriptions.
Parameters: None
Returns:
models: List of available models with id, name, description, and sizetotal_count: Number of available modelsdefault_model: The default model used when not specifiedusage_hint: How to use the model parameter
Example Response:
{
"models": [
{
"id": "u2net",
"name": "U2-Net",
"description": "General purpose background removal model",
"size": "176MB"
},
...
],
"total_count": 8,
"default_model": "u2net",
"usage_hint": "Pass model='model_id' to remove_background tool"
}Development
Setup
# Initialize the development environment
just setupRunning Tests
# Run all tests with coverage
just test
# Run specific test file
poetry run pytest tests/unit/test_constants.py -vCode Quality
# Run formatting
just format
# Run all pre-commit hooks (includes formatting, linting, type-checking)
just validate
# Run type checking only
just typecheckBuilding
# Build wheel package
just package
# Test the built package
just test-package
# Clean build artifacts
just cleanAvailable Just Commands
Command | Description |
| Initialize development environment (Poetry deps + pre-commit hooks) |
| Run unit tests with coverage report |
| Run static type checking with pyright |
| Run formatting hooks (ruff, etc.) |
| Run all pre-commit hooks on all files |
| Build wheel package into dist/ |
| Build, install, and smoke-test the package |
| Clean build artifacts and temporary files |
| Recreate virtual environment with specific Python version |
| Run MCP server with HTTP transport (shared mode) |
| Check if MCP HTTP server is running |
Project Structure
MCP-remove-background/
├── MCP_remove_background/
│ ├── __init__.py # Package exports
│ ├── cli.py # CLI entry point
│ ├── config.py # Configuration management
│ ├── constants.py # Constants and type definitions
│ ├── exceptions.py # Custom exceptions
│ ├── server.py # FastMCP server definition
│ ├── services/
│ │ └── background_remover.py # Core background removal logic
│ ├── tools/
│ │ └── remove_background.py # MCP tool definitions
│ └── utils/
│ └── file_utils.py # File handling utilities
├── tests/
│ ├── conftest.py # Pytest fixtures
│ ├── pytest.ini
│ ├── unit/
│ │ ├── test_constants.py
│ │ ├── test_exceptions.py
│ │ ├── test_background_remover.py
│ │ └── test_tools.py
│ ├── integration/
│ │ └── test_server.py
│ └── mocks/
│ └── rembg_mock.py
├── docs/
│ └── background-removal-mcp-plan.md
├── scripts/
│ ├── spack-ensure.sh
│ └── test-package.sh
├── pyproject.toml
├── justfile
├── README.md
└── spack.yamlSpack Integration
This project uses Spack to manage system-level dependencies (like the Python interpreter). Spack is automatically installed to ~/.local/share/spack if not already available.
To manually activate the Spack environment:
source .spack-activate.shTo update Spack packages:
spack -e . concretize --fresh-roots --force
spack -e . installLicense
MIT License
Available Tools
4 toolsget_model_cache_statusA
Get current status of the model cache.
Returns information about which models are currently loaded, auto-unload settings, and time until automatic unload.
Returns: Dictionary with cache status including loaded models and timeout info.
Inputs: no named parameters. Returns: object
list_background_modelsA
List all available background removal models.
Returns a list of models that can be used for background removal, including their descriptions and recommended use cases.
Returns: Dictionary with models list and default model information.
Inputs: no named parameters. Returns: object
remove_backgroundD
Inputs: image_path (required), model, output_path, alpha_matting, +1 more. Returns: object
unload_modelsA
Unload all cached ML models to free memory.
Call this tool when you're done processing images to free up RAM. ML models can consume 100MB-400MB each. Models will be automatically reloaded on the next background removal request.
Returns: Dictionary with unload status, including list of unloaded models.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: performing the removal, listing available models, unloading models, and checking cache status. Even without a description for remove_background, its name is unambiguous. Tool names and descriptions do not overlap in a way that would cause misselection.
All tool names follow the same imperative verb + object pattern in snake_case: remove, list, unload, get. The naming style is consistent and predictable across the set.
Four tools is well-scoped for a focused background-removal server: one core operation, one model discovery tool, and two resource-management tools. Each tool earns its place without unnecessary bulk.
The tool surface covers the full expected lifecycle for this domain: removing backgrounds, listing available models, checking cache state, and freeing memory. There are no obvious missing operations; model reloading is handled automatically, so an explicit load tool is unnecessary.
Maintenance
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
Remove image backgrounds with U2NetP and return transparent PNG pixels without identifying metadata
Remove image backgrounds free — no account, no watermark, up to 16 MP. Refine edges with a brush, swap in a colour, gradient, or photo, and batch 10 images at once. Developers get a remove.bg-compatible API (50 free images/day) and an MCP server for Claude, Cursor, and VS Code
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseCqualityDmaintenanceA Model Context Protocol server that provides image generation capabilities using the Ideogram API, allowing users to create images from text prompts with customizable parameters.139 npm5MIT
- AlicenseNot gradedqualityDmaintenanceA server that provides AI-powered image generation, modification, and processing capabilities through the Model Context Protocol, leveraging Google Gemini models and other image services.19MIT
- AlicenseNot gradedqualityDmaintenanceA server that implements the Model Context Protocol, providing a standardized way to connect AI models to different data sources and tools.10 npm12MIT
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol server that enables AI-powered image generation through Stability AI and Black Forest Labs APIs, allowing users to create images from detailed text prompts with customizable settings and comprehensive metadata tracking.MIT