← Back to all products

MCP Server Starter

$49

Production-shaped remote MCP server starter — Streamable HTTP on Cloudflare Workers, stateless + stateful patterns, typed tools, discovery, rate limiting, and Vitest tests.

11 filesv1.0.0 (updated 2026-08-02)
MarkdownTOMLTypeScriptJSON

File Structure 11 files

mcp-server-starter/ ├── LICENSE ├── README.md ├── package.json ├── src/ │ ├── descriptor.ts │ ├── ratelimit.ts │ ├── server.ts │ ├── transport.ts │ └── worker.ts ├── test/ │ └── server.test.ts └── wrangler.toml

Documentation Preview README excerpt

MCP Server Starter — Remote Streamable HTTP on Cloudflare Workers

A production-shaped starter for building a **remote Model Context Protocol (MCP)

server** that any MCP client (Claude Desktop, Cursor, Cline, OpenCode, or your own

agent) can connect to over the network. It uses the Streamable HTTP transport

and runs on Cloudflare Workers (or any Web-standard runtime: Deno, Bun, Node 18+).

This is the exact shape used to ship a live, registry-listed commerce MCP server —

generalized, anonymized, and reduced to a clean starting point you can extend.

Why this exists

Most MCP tutorials show a local stdio server. Real agents increasingly connect

to remote servers over HTTP. Remote servers are harder: you have to handle the

Streamable HTTP transport correctly, decide between stateless and session modes,

run inside a serverless runtime with no Node built-ins, and expose a discovery

surface so clients can find you. This starter solves all of that.

Features

  • Streamable HTTP transport — Web-standard Request/Response, works on

Workers/Deno/Bun with no Node-only APIs.

  • Stateless mode by default — a fresh server per request, no Durable Objects

required; ideal for read-heavy public tools. A documented path to stateful

sessions is included.

  • Typed tools with zod schemas — two worked example tools (echo, add) show

input validation, structured content, and error contracts.

  • Friendly discovery — a plain GET /mcp returns a JSON descriptor instead of

an opaque 406, plus a /.well-known/mcp.json manifest.

  • Rate limiting — a token-bucket limiter (in-memory, with a KV upgrade note).
  • Tests — a Vitest suite that drives the server through the transport end to

end (initialize, tools/list, tools/call).

Requirements

  • Node.js 18+ (for local dev and tests)
  • A Cloudflare account (free tier is fine) for deployment
  • npm

Quick start


npm install
npm test            # runs the Vitest suite against the in-process server
npm run dev         # wrangler dev — serves /mcp locally

Point an MCP client at http://localhost:8787/mcp (Streamable HTTP). Or smoke-test

with curl:


curl http://localhost:8787/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

File tree



*... continues with setup instructions, usage examples, and more.*

Code Sample .ts preview

src/descriptor.ts /** * descriptor.ts — machine-discovery for the server. * * A plain GET to /mcp (from a browser or a crawler) should not return an opaque * 406. Return a small JSON descriptor instead, and mirror it at * /.well-known/mcp.json so clients and registries can discover the endpoint. */ import { SERVER_INFO, TOOL_NAMES } from './server.js'; export function descriptor(baseUrl: string): Record<string, unknown> { return { name: SERVER_INFO.name, version: SERVER_INFO.version, protocol: 'mcp', protocol_version: '2025-06-18', transport: 'streamable-http', endpoint: `${baseUrl}/mcp`, tools: [...TOOL_NAMES], usage: 'POST JSON-RPC 2.0 with Accept: application/json, text/event-stream. Example: {"jsonrpc":"2.0","id":1,"method":"tools/list"}', }; } /** True when the request is a real MCP protocol call (vs a discovery GET). */ export function isMcpCall(req: Request): boolean { if (req.method === 'POST') return true; return (req.headers.get('accept') ?? '').includes('text/event-stream'); }