cloudflare-mcp-server
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCloudflare MCP Server
Cloudflare MCP Server
Last Updated: 2025-11-21
最后更新:2025-11-21
Quick Start
快速开始
typescript
import { McpServer } from '@modelcontextprotocol/sdk';
const server = new McpServer({
name: 'my-server',
version: '1.0.0'
});
server.tool('getTodo', async ({ id }) => ({
id,
title: 'Task',
completed: false
}));
export default server;typescript
import { McpServer } from '@modelcontextprotocol/sdk';
const server = new McpServer({
name: 'my-server',
version: '1.0.0'
});
server.tool('getTodo', async ({ id }) => ({
id,
title: 'Task',
completed: false
}));
export default server;Core Concepts
核心概念
- Tools: Functions AI can call
- Resources: Data AI can access
- Prompts: Reusable templates
- Transports: SSE, HTTP, WebSocket
- 工具:AI可调用的函数
- 资源:AI可访问的数据
- 提示词:可复用模板
- 传输方式:SSE、HTTP、WebSocket
Example Tool
示例工具
typescript
server.tool('searchDocs', {
description: 'Search documentation',
parameters: {
type: 'object',
properties: {
query: { type: 'string' }
}
},
handler: async ({ query }) => {
return { results: [...] };
}
});typescript
server.tool('searchDocs', {
description: 'Search documentation',
parameters: {
type: 'object',
properties: {
query: { type: 'string' }
}
},
handler: async ({ query }) => {
return { results: [...] };
}
});Resources
资源
Core Documentation
核心文档
- (704 lines) - Official Cloudflare templates, complete step-by-step workflow, 5-minute setup
references/quick-start-guide.md - (66 lines) - MCP fundamentals: tools, resources, prompts, transports
references/core-concepts.md - (326 lines) - Worker & Durable Objects basics, transport selection, HTTP fundamentals
references/worker-basics.md - (246 lines) - Durable Objects integration, WebSocket hibernation, cost optimization, common patterns
references/stateful-servers.md - (814 lines) - Deployment & testing, configuration reference, authentication patterns, 22 known errors with solutions
references/production-deployment.md
- (704行)- 官方Cloudflare模板、完整分步流程、5分钟快速搭建
references/quick-start-guide.md - (66行)- MCP基础:工具、资源、提示词、传输方式
references/core-concepts.md - (326行)- Worker与Durable Objects基础、传输方式选择、HTTP基础知识
references/worker-basics.md - (246行)- Durable Objects集成、WebSocket休眠、成本优化、常见模式
references/stateful-servers.md - (814行)- 部署与测试、配置参考、认证模式、22个已知错误及解决方案
references/production-deployment.md
Templates
模板
- - Minimal MCP server
templates/basic-mcp.ts - - Tool definitions
templates/tools-example.ts - - Stateful MCP with DO
templates/durable-object-mcp.ts - - WebSocket transport
templates/websocket-mcp.ts
Official Docs: https://modelcontextprotocol.io | Cloudflare: https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
- - 极简MCP服务器
templates/basic-mcp.ts - - 工具定义示例
templates/tools-example.ts - - 基于DO的有状态MCP服务器
templates/durable-object-mcp.ts - - WebSocket传输方式
templates/websocket-mcp.ts