Building a Rust MCP tool on Cloudflare Workers
Start with one read-only tool and follow a request from its JSON arguments to the revision it returns.
Make one operation useful
For a publishing platform, a good first tool is get_revision. Give it a project ID and a revision ID. Return a small manifest with the revision title, page paths and asset references. The caller can use that manifest to decide what to edit next. Keeping the response small also makes the operation practical when a project contains large images.
Draw the runtime boundary
Cloudflare’s Rust tooling compiles Worker code to WebAssembly. Keep argument parsing and manifest validation in ordinary Rust functions. Put the platform-specific request handling, storage bindings and response conversion at the edge of the crate. Treat MCP as its own protocol layer. A JSON endpoint becomes useful to an MCP client when the server also handles the appropriate lifecycle, tool discovery and tool calls for its supported protocol version.
Test the contract before adding writes
Start with a fixture containing two projects whose revision names coincide. Derive identity from the authenticated request and constrain the lookup by authorised project. Exercise a missing revision, malformed arguments and an unavailable storage binding. Return errors the client can distinguish without exposing internal object keys or credentials. Once that path works, design save_revision separately with an expected parent revision and an idempotency key. Retrying a client call should produce one logical edit.