This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
mochify-cli is a Rust CLI tool and MCP server that wraps the mochify.xyz image processing API (POST https://api.mochify.xyz/v1/squish). It uploads local images via multipart form and saves the processed result.
# Build
cargo build
# Build release
cargo build --release
# Check (fast, no binary output)
cargo check
# Run (process an image)
cargo run -- photo.jpg -t webp -w 800
# Run MCP server on stdio
cargo run -- serve
# Run tests
cargo test
# Run a single test
cargo test <test_name>
# Lint
cargo clippy
# Format
cargo fmtsrc/
main.rs Async entry point. Parses CLI args (clap), dispatches:
- `serve` subcommand → starts MCP server on stdio
- no subcommand → calls process_files()
cli.rs Clap `Args` struct and `Commands` enum (Serve subcommand)
api.rs `MochifyClient` + `ProcessParams` — all HTTP logic.
`squish()` builds a multipart POST, writes response bytes to disk.
mcp/
mod.rs Re-exports MochifyMcp
tools.rs `MochifyMcp` struct implements ServerHandler via rmcp macros.
Exposes a single `squish` tool whose schema mirrors ProcessParams.
- Single tool in MCP mode — the MCP client (e.g. Claude) handles natural-language interpretation and maps prompts to structured
squishtool parameters. No NLP layer needed in the CLI. - Auth is optional — without
--api-key/MOCHIFY_API_KEY, requests go through on the free tier (25/day). The key is sent asAuthorization: Bearer <key>. - rmcp macros pattern — tools use
#[tool_router]on the impl block +#[tool_handler]onimpl ServerHandler. The struct must have atool_router: ToolRouter<Self>field initialized viaSelf::tool_router().
| Parameter | Form field | Type |
|---|---|---|
| Image file | file |
multipart bytes |
| Format | type |
jpg | png | webp | avif | jxl |
| Width | width |
u32 |
| Height | height |
u32 |
| Crop | crop |
bool |
| Rotation | rotation |
0 / 90 / 180 / 270 |
{
"mcpServers": {
"mochify": {
"command": "/path/to/mochify-cli",
"args": ["serve"],
"env": { "MOCHIFY_API_KEY": "your-key" }
}
}
}