Build a remote MCP server on Cloudflare Pages without an SDK (about 200 lines of TypeScript) A developer published a roughly 200-line TypeScript implementation of a stateless, tools-only MCP server running on Cloudflare Pages Functions, handling the Streamable HTTP transport with a single JSON-RPC POST handler and no SDK, session store or long-lived process. The server, live at agentwright.app/mcp, exposes Claude API pricing and cost-estimation tools to clients such as Claude Code, Claude Desktop and Cursor, and answers GET requests with 405 to signal no server stream. The writeup stresses echoing the client's protocol version when supported and returning tool failures as results with isError: true rather than JSON-RPC protocol errors so models can correct their calls. If your MCP server only answers questions look something up, compute something, return text , you do not need a framework, a session store or a long-lived process. One HTTP handler that speaks JSON-RPC is enough, and it runs for free on Cloudflare Pages Functions or Workers. This post walks through the server we run at https://agentwright.app/mcp . It gives Claude, Cursor or any MCP client current Claude API prices and cost estimates. The full source is public in functions/mcp.ts https://github.com/agentwright-app/site/blob/main/functions/mcp.ts ; the snippets below are trimmed from it. With the Streamable HTTP transport, everything goes to one URL as an HTTP POST with a JSON-RPC body. For a tools-only server, a client session looks like this: initialize : the client sends the protocol version it wants and its capabilities. You answer with the version you will speak, your capabilities and your name. notifications/initialized : a notification no id , so there is nothing to answer. Reply 202 Accepted with an empty body. tools/list : return your tool definitions with JSON Schema inputs. tools/call : run one tool and return its result as content blocks. Add ping answer {} and you have covered what Claude Code, Claude Desktop, Cursor and the official SDK client do with a tools-only server. The transport also lets a server answer with a text/event-stream and open a GET stream for server-to-client messages. Both are optional. If every answer is a single JSON object, reply with Content-Type: application/json , and answer GET with 405 Method Not Allowed ; clients treat that as "no server stream" and carry on. js export const onRequestPost: PagesFunction = async { request } = { const text = await request.text ; if text.length 64 000 return json rpcError null, -32600, "Request too large" , 413 ; let body: unknown; try { body = JSON.parse text ; } catch { return json rpcError null, -32700, "Parse error" , 400 ; } const out = handle body as Rpc ; // null for notifications return out ? json out : new Response null, { status: 202 } ; }; export const onRequestGet: PagesFunction = async = new Response "Method Not Allowed", { status: 405, headers: { allow: "POST, OPTIONS" } } ; handle is a plain switch on msg.method : function handle msg: Rpc : object | null { if msg.id === undefined || msg.id === null return null; // notification switch msg.method { case "initialize": return ok msg.id, { protocolVersion: SUPPORTED.includes msg.params?.protocolVersion ? msg.params.protocolVersion : SUPPORTED 0 , capabilities: { tools: { listChanged: false } }, serverInfo: { name: "claude-pricing", version: "1.0.0" }, } ; case "ping": return ok msg.id, {} ; case "tools/list": return ok msg.id, { tools: TOOLS } ; case "tools/call": return ok msg.id, runTool msg.params?.name, msg.params?.arguments ?? {} ; default: return rpcError msg.id, -32601, Method not found: ${msg.method} ; } } Two details matter here. Version negotiation. Echo the client's protocolVersion if you support it, otherwise answer with your newest one. A stateless tools-only server behaves the same under the recent spec versions, so supporting several costs nothing. Two kinds of errors. An unknown method or unknown tool is a protocol error: a JSON-RPC error object. A tool that ran but could not do the job bad model name, negative token count should return a normal result with isError: true and a readable message. The model sees that text and can correct its own call. If you throw a protocol error instead, many clients show a generic failure and the model never learns what went wrong. function runTool name: string, args: Record