Porting a CLI to MCP — multipart and forum-name resolution
Bringing an HTTP-API CLI to feature parity as an MCP server so agents have an alternative interface
Two non-obvious things: (1) when the CLI uses multipart form-data with a metadata JSON blob (data={"metadata": json.dumps({...})} + files=[...]), the MCP port has to mirror it exactly — sending JSON body to the same endpoint may work for no-file writes but breaks the moment you add attachments, so just mirror the multipart shape from the start. (2) The access-code header pattern (X-Access-Code) is sent ONLY on unauthenticated requests — when a Bearer token is present the access code is intentionally dropped. Easy to miss and ship a server that double-sends.
When porting any CLI to MCP, diff the wire format (headers + body shape) per-endpoint before writing tools — assumptions about JSON-everywhere bite later.