Skip to main content
Glama
Tattzy25

Hello MCP Server

by Tattzy25

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 turns an McpServer factory into a Worker-compatible fetch handler

  • Minimal setup — define tools in a factory, pass the factory to createMcpHandler, done

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

Related MCP server: sentiment-analyzer

Running

pnpm install
pnpm start

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 { McpServer } from "@modelcontextprotocol/server";
import { createMcpHandler } from "agents/mcp/server";
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(request, env, ctx) {
    return createMcpHandler(createServer)(request, env, ctx);
  }
} satisfies ExportedHandler;

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to greet users in 7 different languages including English, Spanish, French, German, Japanese, Chinese, and Korean. A lightweight multilingual greeting tool for the Model Context Protocol.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A simple MCP server built with Next.js that provides a greet_user tool to return friendly greetings, either general or personalized.
    10 npm
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Exposes a greet tool that takes a name and returns a greeting message.
    5 npm
    ISC