Skip to main content
Glama
Hello MCP Server

Hello MCP Server

by kasugaiii417

MCP Server (createMcpHandler)

The simplest way to run a stateless MCP server on Cloudflare Workers. Uses createMcpHandler from the Agents SDK to handle all MCP protocol details in one line.

What it demonstrates

  • createMcpHandler — the Agents SDK helper that wraps an McpServer into a Worker-compatible fetch handler

  • Minimal setup — define tools on an McpServer, pass it to createMcpHandler, done

  • Stateless — no Durable Objects, no persistent state, each request is independent

Related MCP server: mcp-worker

Running

npm install
npm run dev

Open the browser to see the built-in tool tester, or connect with the MCP Inspector at http://localhost:5173/mcp.

How it works

import { createMcpHandler } from "agents/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

function createServer() {
  const server = new McpServer({ name: "Hello MCP Server", version: "1.0.0" });
  server.registerTool(
    "hello",
    {
      description: "Returns a greeting",
      inputSchema: { name: z.string().optional() }
    },
    async ({ name }) => ({
      content: [{ type: "text", text: `Hello, ${name ?? "World"}!` }]
    })
  );
  return server;
}

export default {
  fetch: async (request, env, ctx) => {
    const server = createServer();
    return createMcpHandler(server)(request, env, ctx);
  }
};

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      A stateless MCP server for Cloudflare Workers that uses createMcpHandler to expose a simple greeting tool, requiring no persistent state.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A minimal, stateless MCP server that runs on Cloudflare Workers using createMcpHandler from the Agents SDK. It demonstrates a simple 'hello' tool and requires no Durable Objects or persistent state.
      -
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables running a stateless MCP server on Cloudflare Workers with a simple greeting tool, handling MCP protocol details via createMcpHandler.
      -