Skip to main content
Glama

MCP Server (createMcpHandler)

Самый простой способ запустить MCP-сервер без сохранения состояния на Cloudflare Workers. Использует createMcpHandler из Agents SDK для обработки всех деталей протокола MCP в одной строке.

Что демонстрируется

  • createMcpHandler — вспомогательная функция Agents SDK, которая превращает фабрику McpServer в обработчик fetch, совместимый с Workers

  • Минимальная настройка — определите инструменты в фабрике, передайте фабрику в createMcpHandler, готово

  • Без состояния — никаких Durable Objects, никакого постоянного состояния, каждый запрос независим

Related MCP server: createMcpHandler MCP Server

Запуск

pnpm install
pnpm start

Откройте браузер, чтобы увидеть встроенный тестер инструментов, или подключитесь с помощью MCP Inspector по адресу http://localhost:5173/mcp.

Как это работает

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;

Связанные примеры

  • mcp — MCP-сервер с сохранением состояния с помощью McpAgent и Durable Objects

  • mcp-worker-authenticated — добавление OAuth-аутентификации

  • mcp-client — подключение к MCP-серверам в качестве клиента

F
license - not found
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

  • Cloudflare Workers MCP server: crypto-signal

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Indxxr/mcp-worker'

If you have feedback or need assistance with the MCP directory API, please join our Discord server