MCP Worker Server
MCP 服务器 (createMcpHandler)
在 Cloudflare Workers 上运行无状态 MCP 服务器的最简单方法。使用 Agents SDK 中的 createMcpHandler 一行代码处理所有 MCP 协议细节。
它演示了什么
createMcpHandler— Agents SDK 的辅助函数,将McpServer工厂转换为 Workers 兼容的 fetch 处理器最简设置 — 在工厂中定义工具,将工厂传递给
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— 使用McpAgent和 Durable Objects 的有状态 MCP 服务器mcp-worker-authenticated— 添加 OAuth 身份验证mcp-client— 作为客户端连接到 MCP 服务器
This server cannot be installed
Maintenance
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
- Flicense-qualityCmaintenanceRun a stateless MCP server on Cloudflare Workers using createMcpHandler.
- Alicense-qualityCmaintenanceSimplest way to run a stateless MCP server on Cloudflare Workers, using createMcpHandler from the Agents SDK to handle MCP protocol details in one line.10MIT
- Flicense-qualityCmaintenanceDeploy a stateless remote MCP server on Cloudflare Workers without authentication, with custom tool support and compatibility for MCP clients.
- Flicense-qualityCmaintenanceDeploys a stateless remote MCP server on Cloudflare Workers without authentication, supporting the MCP 2026-07-28 specification and custom tool registration.
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Cloudflare Workers MCP server: crypto-signal
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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