Remote MCP Server Builder

Generate a production-ready Cloudflare Workers remote MCP server in 60 seconds β€” Streamable HTTP transport, three auth modes, custom tools and an optional ui:// MCP App widget. Test the result instantly in the Inspector and OAuth 2.1 Debugger.

Configure your MCP server
Acme Analytics Β· lowercase kebab-case
Generated starter
// Acme Analytics MCP β€” Remote MCP server on Cloudflare Workers.
// Generated by https://remotemcp.net/generator β€” test it at
//   https://remotemcp.net/inspector?url=https%3A%2F%2Fmcp.acme.com%2Fmcp

interface Env {
}

const CORS: Record<string, string> = {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
    "Access-Control-Allow-Headers": "Content-Type, Authorization, Mcp-Session-Id, MCP-Protocol-Version",
    "Access-Control-Expose-Headers": "Mcp-Session-Id, WWW-Authenticate",
};

const TOOLS = [
    {
        name: "run_query",
        description: "Run a named analytics query and return rows as JSON.",
        inputSchema: {
                "type": "object",
                "properties": {
                        "query": {
                                "type": "string",
                                "description": "Query key or SQL"
                        },
                        "limit": {
                                "type": "number",
                                "description": "Row limit"
                        }
                },
                "required": [
                        "query"
                ]
        }, annotations: { readOnlyHint: true },
    }
];

const rpc = (id: unknown, result: unknown) => ({ jsonrpc: "2.0", id: id ?? null, result });
const rpcErr = (id: unknown, code: number, message: string) => ({ jsonrpc: "2.0", id: id ?? null, error: { code, message } });

function handleRpc(method: string, params: Record<string, unknown>, id: unknown): unknown | null {
    switch (method) {
        case "initialize":
            return rpc(id, {
                protocolVersion: "2025-03-26",
                capabilities: { tools: {} },
                serverInfo: { name: "acme-analytics", version: "1.0.0" },
            });
        case "ping":
            return rpc(id, {});
        case "tools/list":
            return rpc(id, { tools: TOOLS });
        case "tools/call": {
            const name = typeof params.name === "string" ? params.name : "";
            const args = (params.arguments ?? {}) as Record<string, unknown>;
            switch (name) {
        case "run_query":
            // TODO: call your real backend here.
            return { content: [{ type: "text", text: JSON.stringify({ tool: name, args, note: "stub β€” wire this tool to your API" }, null, 2) }] };
                default:
                    return { content: [{ type: "text", text: `Unknown tool '${name}'` }], isError: true };
            }
        }
        default:
            if (method.startsWith("notifications/")) return null; // 202
            return rpcErr(id, -32601, `Method not found: ${method}`);
    }
}

export default {
    async fetch(request: Request, env: Env): Promise<Response> {
        const url = new URL(request.url);

        if (request.method === "OPTIONS") return new Response(null, { status: 204, headers: CORS });

    if (url.pathname === "/.well-known/oauth-protected-resource") {
        // RFC 9728 Protected Resource Metadata β€” points clients at your AS.
        const body = {
            resource: `${url.origin}/mcp`,
            authorization_servers: [env.AUTH_SERVER_ISSUER ?? "https://your-auth-server.example.com"],
            scopes_supported: ["mcp:read", "mcp:write"],
            bearer_methods_supported: ["header"],
        };
        return new Response(JSON.stringify(body, null, 2), { headers: { "Content-Type": "application/json", ...CORS } });
    }
        if (url.pathname === "/.well-known/mcp.json") {
            const card = {
                name: "com.acmeanalytics/server",
                title: "Acme Analytics MCP",
                description: "Analytics query & reporting tools exposed as a remote MCP server.",
                version: "1.0.0",
                homepageUrl: `${url.origin}`,
                remotes: [{ type: "streamable-http", url: `${url.origin}/mcp` }],
                authentication: { type: "none" },
                capabilities: { tools: true },
            };
            return new Response(JSON.stringify(card, null, 2), { headers: { "Content-Type": "application/json", ...CORS } });
        }

        if (url.pathname === "/mcp" && request.method === "POST") {
            let payload: unknown;
            try {
                payload = await request.json();
            } catch {
                return new Response(JSON.stringify(rpcErr(null, -32700, "Parse error")), { status: 400, headers: { "Content-Type": "application/json", ...CORS } });
            }
            const reqs = Array.isArray(payload) ? payload : [payload];
            const out: unknown[] = [];
            for (const r of reqs as { id?: unknown; method?: string; params?: Record<string, unknown> }[]) {
                if (!r || typeof r.method !== "string") continue;
                if (r.id === undefined && r.method.startsWith("notifications/")) continue;
                const res = handleRpc(r.method, r.params ?? {}, r.id);
                if (res !== null) out.push(res);
            }
            if (out.length === 0) return new Response(null, { status: 202, headers: CORS });
            return new Response(JSON.stringify(Array.isArray(payload) ? out : out[0]), {
                headers: { "Content-Type": "application/json", ...CORS },
            });
        }

        return new Response(`Acme Analytics MCP β€” MCP endpoint at /mcp\n`, { headers: CORS });
    },
} satisfies ExportedHandler<Env>;

Frequently asked questions

How do I build a remote MCP server?

Pick a preset above, edit your tools visually, and download the .zip β€” it's a complete Cloudflare Workers project implementing the MCP Streamable HTTP transport at POST /mcp. Run npm install && npx wrangler deploy and your server is live on the edge in under a minute.

How do I add authentication to an MCP server?

Select Bearer API Key for a simple Authorization: Bearer check backed by a Wrangler secret, or OAuth 2.1 to generate a full RFC 9728 protected-resource flow: /.well-known/oauth-protected-resource metadata, a compliant 401 WWW-Authenticate challenge and CORS expose headers β€” ready for WorkOS, Clerk, Stytch or Auth0.

Where can I find an example of a Streamable HTTP MCP server?

The generated src/index.ts is a complete example: it handles CORS preflight, JSON-RPC initialize / tools/list / tools/call / notifications, resources for MCP Apps ui:// widgets, plus /.well-known/mcp.json Server Card discovery β€” zero external dependencies.

How do I test my generated MCP server?

Every generated README embeds one-click badges pointing at the RemoteMCP.net Inspector and OAuth 2.1 Debugger β€” paste your /mcp URL to run real tool calls and validate the full OAuth 2.1 challenge chain without installing anything.