Skip to main content
Glama
ReverserID

rembg-mcp

by ReverserID
README.md
# rembg-mcp

MCP server wrapping [rembg](https://github.com/danielgatis/rembg) for GPU-accelerated image background removal. Uses `onnxruntime-gpu` (CUDA) with automatic CPU fallback. No API keys — models run locally.

## Install (GPU / CUDA)

Requires an NVIDIA GPU with CUDA 12.x runtime. Python 3.10–3.12.

```bash
uv tool install --python 3.12 "git+https://github.com/ReverserID/rembg-mcp.git"
```

Or from a local clone:

```bash
cd rembg-mcp
uv tool install --python 3.12 .
```

## MCP client config

```json
{
  "mcpServers": {
    "rembg": {
      "command": "rembg-mcp"
    }
  }
}
```

Claude Code:

```bash
claude mcp add rembg -- rembg-mcp
```

## Environment variables

| Var | Default | Description |
|-----|---------|-------------|
| `REMBG_MODEL` | `u2net` | Default model |
| `REMBG_OUTPUT_DIR` | `./rembg-output` | Where cutouts are saved |
| `REMBG_FORCE_CPU` | `` | Set to `1` to disable GPU |

## Tools

- **`remove_background`** — cut out background from an image on disk, save transparent PNG. Options: `model`, `alpha_matting` (better hair/fur edges), `post_process_mask`, `only_mask`, `bgcolor` (`"R,G,B,A"` to composite onto a flat color).
- **`remove_background_base64`** — same, but image in/out as base64 (no disk).
- **`list_models`** — curated model catalog.
- **`gpu_status`** — show ONNX Runtime providers and whether CUDA is active.
- **`unload_sessions`** — free loaded models from GPU/CPU memory.

## Models

`u2net` (default), `u2netp`, `u2net_human_seg`, `u2net_cloth_seg`, `silueta`, `isnet-general-use`, `isnet-anime`, `birefnet-general`, `birefnet-general-lite`, `birefnet-portrait`, `sam`. Any other rembg model name also works.

Models download on first use and cache under `~/.u2net`.

## Notes

- First `remove_background` call downloads the model and initializes CUDA — slower; subsequent calls reuse the cached session.
- Check `gpu_status` to confirm `CUDAExecutionProvider` is active.

## License

MIT

Maintenance

ActivitySlowing
ResponsivenessNo issues