SVG Preflight MCP
A small, dependency-free MCP server for checking image crop geometry and calculating proportional output sizes before a raster-to-vector handoff. It runs locally over stdio with Python 3.10 or newer.
This is executable software, separate from the publisher's prompt-only image preparation Skill. It exposes two deterministic tools. It does not open image files, call a model, upload artwork, perform vector tracing, or connect to a remote service. No API key or account is needed.
Install and run
Clone or download this repository, then run:
python3 server.py
The process waits for newline-delimited MCP JSON-RPC messages on standard input. It writes protocol messages only to standard output. It is not an interactive text chat or an HTTP endpoint.
For a client that supports local stdio MCP servers, configure the absolute file path for your checkout:
{
"mcpServers": {
"svg-preflight": {
"command": "python3",
"args": ["/absolute/path/to/svg-preflight-mcp/server.py"]
}
}
}
Use the configuration location documented by your client. The included tests exercise a real subprocess handshake, tool discovery and invocation; they do not establish end-to-end compatibility with every desktop client.
Tools
validate_crop
Required integers: source_width, source_height, x, y, width, height.
The origin is the original image's top-left corner, not the top-left corner of a scaled preview. Coordinates may be zero; dimensions must be positive. Each input is limited to 1,000,000. A crop that exceeds an image edge returns valid: false, together with its right/bottom edges and pixel areas. Invalid input types return a tool error.
For example, a 2400 × 1600 source with x=1200, y=400, width=1200, height=1200 fits exactly against the right and bottom edges. Moving that crop one pixel to the right makes it invalid. This is useful when translating a screen selection back into source-image coordinates.
fit_dimensions
Required integers: width, height, max_width, max_height. Optional boolean: allow_upscale, default false.
A 1200 × 1200 crop fitted within 600 × 800 produces 600 × 600. A 2400 × 1600 image fitted within 600 × 600 produces 600 × 400. Smaller sources remain at their original size unless upscaling is explicitly enabled. Output sides are floored to whole pixels with a one-pixel minimum; the result includes the theoretical scale and the resulting aspect-ratio rounding error. Very narrow images can therefore have noticeable rounding error, which a caller should inspect.
Protocol and verification
Implements initialization/version negotiation, the initialized notification, ping, tools/list, and tools/call. Supported versions are 2025-11-25, 2025-06-18 and 2024-11-05. Tools are annotated read-only and idempotent. There are no file, shell, browser, credential or network tools.
python3 -m unittest -v test_server.py
The tests cover edge-aligned and out-of-bounds crops, no-upscale/default sizing, explicit upscaling, invalid numbers/types, tool discovery, unknown tool handling and the actual stdio subprocess exchange.
Protocol references: stdio transport, lifecycle, and tools.
Optional visual handoff
After calculating bounds and sizes, use your preferred image editor. The same publisher maintains JPG to SVG's browser image editor for local cropping, resizing, raster export and SVG tracing. This MCP server does not control that website or expose its conversion engine. The website has its own file limits and anonymous usage analytics; this standalone calculator has no analytics or network calls.
License
MIT. Only this independent utility, documentation and tests are distributed here; no product core code or user artwork is included.