Cloudflare MCP Server — Code Mode
Cloudflare MCP Server — 代码模式
无服务器入门模板,用于在 Cloudflare Workers 上构建远程 Model Context Protocol (MCP) 服务器。
该项目专为 代码模式 设计:客户端可以发现能力,并根据结构化响应组合工具调用。入门模板中不启用任意代码执行;只有在定义了沙箱、身份验证、限制和审计之后,才应添加该能力。
目标
通过 Cloudflare Workers 在边缘运行。
在
/mcp暴露一个 MCP 端点。保持工具小巧、类型化且可组合。
准备 OAuth 身份验证和 Cloudflare 绑定。
后续在隔离沙箱中实现安全的代码执行。
Related MCP server: remote-mcp-server-authless01
本地开发
先决条件:Node.js 18+ 以及一个启用了 Workers 的 Cloudflare 账户。
npm install
npm run dev本地服务器在 http://localhost:8788/mcp 运行。
使用 MCP Inspector 验证:
npx @modelcontextprotocol/inspector@latest部署
npx wrangler login
npm run deploy部署完成后,端点将是:
https://<worker>.<account>.workers.dev/mcp结构
src/index.ts:Worker 的 HTTP 路由。src/mcp.ts:MCP 服务器和工具。wrangler.jsonc:Worker 的配置。PLAN.md:实现计划和验收标准。
安全
不要直接在 Worker 中添加 eval、new Function 或代码解释器。对于真正执行代码的代码模式,请使用合适的沙箱、强身份验证、API 允许列表、CPU/内存/时间限制、用户级隔离,以及不含敏感信息的日志。
后续步骤
参见 PLAN.md。
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloudflare Workers MCP server: agent-workflow-engine
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
Hosted MCP runtime where your agent publishes its own tools by tool call and keeps working.
Discover and call 10,000+ production APIs from one MCP server. Pay-per-call billing for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceDeploy a stateless remote MCP server on Cloudflare Workers without authentication, enabling tool calls via MCP protocol.-
- FlicenseNot gradedqualityCmaintenanceA stateless remote MCP server on Cloudflare Workers without authentication, supporting custom tool registration and integration with MCP clients like Cloudflare AI Playground and Claude Desktop.-
- FlicenseNot gradedqualityBmaintenanceDeploys a stateless remote MCP server on Cloudflare Workers without authentication, enabling MCP tool calls from clients like Claude Desktop and Cloudflare AI Playground.-
- FlicenseNot gradedqualityCmaintenanceEnables deploying a stateless remote MCP server on Cloudflare Workers without authentication, implementing the MCP 2026-07-28 specification and compatible with legacy clients for tool calls.-