Summary
I'd like to propose adding a lightweight MCP (Model Context Protocol) wrapper server so LLMs like Claude can use imgcompress as a tool directly, without a human operating the UI.
Motivation
imgcompress is a capable image processing backend, but it currently only has a browser-based frontend as its client. With the rise of AI agents and LLM-driven workflows, there's a growing need for tools that can be invoked programmatically by models. An MCP server bridges that gap — it exposes the existing REST API as structured tools that any MCP-compatible LLM can call.
Proposed approach
-
Transport: stdio (the LLM client spawns the server as a local process — no new ports, no new attack surface)
-
Architecture: pure proxy — no business logic, no changes to the backend. All calls go through the existing REST API, exactly as the browser does
-
New dependencies: mcp[cli], httpx (Python, isolated in mcp/)
-
Structure:
mcp/
pyproject.toml ← dependencies (mcp[cli], httpx)
server.py ← FastMCP server, 6 tools
-
Tools exposed:
| Tool |
Endpoint |
compress_images |
POST /api/compress |
remove_background |
POST /api/compress with use_rembg=true |
download_file |
GET /api/download |
download_all |
GET /api/download_all |
list_supported_formats |
GET /api/images_supported |
health_check |
GET /api/health/backend |
-
Security model is unchanged: the LLM never touches the container directly. The REST API remains the only entry point — the MCP server is just a new client of it.
Example use cases
- An AI coding agent generates a logo in SVG and immediately converts and compresses it — no human in the loop
- Claude assembles a document and optimizes all images before exporting
- Batch background removal from a single prompt: "remove the background from these 20 images"
What I have ready
I have a working implementation on my fork, tested end-to-end against a running imgcompress container. Claude Desktop picks it up automatically via the standard MCP connector config. I can open a PR if this direction sounds good to you.
Questions before opening a PR
- Is MCP integration something you'd want in the project?
- Should
mcp/ live at the repo root, or would you prefer it under a contrib/ or integrations/ directory?
- Any preference on whether the
mcp/ environment should use uv (consistent with the rest of the project) instead of plain pip?
Happy to adjust the approach based on your feedback.
Summary
I'd like to propose adding a lightweight MCP (Model Context Protocol) wrapper server so LLMs like Claude can use imgcompress as a tool directly, without a human operating the UI.
Motivation
imgcompress is a capable image processing backend, but it currently only has a browser-based frontend as its client. With the rise of AI agents and LLM-driven workflows, there's a growing need for tools that can be invoked programmatically by models. An MCP server bridges that gap — it exposes the existing REST API as structured tools that any MCP-compatible LLM can call.
Proposed approach
Transport: stdio (the LLM client spawns the server as a local process — no new ports, no new attack surface)
Architecture: pure proxy — no business logic, no changes to the backend. All calls go through the existing REST API, exactly as the browser does
New dependencies:
mcp[cli],httpx(Python, isolated inmcp/)Structure:
Tools exposed:
compress_imagesPOST /api/compressremove_backgroundPOST /api/compresswithuse_rembg=truedownload_fileGET /api/downloaddownload_allGET /api/download_alllist_supported_formatsGET /api/images_supportedhealth_checkGET /api/health/backendSecurity model is unchanged: the LLM never touches the container directly. The REST API remains the only entry point — the MCP server is just a new client of it.
Example use cases
What I have ready
I have a working implementation on my fork, tested end-to-end against a running imgcompress container. Claude Desktop picks it up automatically via the standard MCP connector config. I can open a PR if this direction sounds good to you.
Questions before opening a PR
mcp/live at the repo root, or would you prefer it under acontrib/orintegrations/directory?mcp/environment should useuv(consistent with the rest of the project) instead of plainpip?Happy to adjust the approach based on your feedback.