rest-mcp
v0.0.3
Published
This exposes your MCP over rest so you can easily use it in your APIs without painful RPC
Readme
This exposes your MCP over rest so you can easily use it in your APIs without painful RPC
REST to MCP conversion rules:
- Path params come from URL segments after method name
- Required simple params (string/number/boolean) go in query params
- Optional simple params go in query params
- Complex objects/arrays go in request body
- Special case for tools/call: POST body or GET query params become "arguments"
For example, a toolcall to tool add becomes /tools/call/add?a=1&b=1
Note: This focuses on a REST-suitable subset of MCP methods. Server to client methods or streaming methods like notifications are omitted.
Usage:
import { convertRestToMcp } from "rest-mcp";
export default {
fetch: async (request) => {
if (new URL(request.url).pathname === "/mcp") {
return handleMcp(request);
}
// Handle rest over mcp
const mcpRequest = await convertRestToMcp(request);
if (mcpRequest) {
return handleMcp(mcpRequest);
}
return new Response("Not found");
},
};