Workers MCP Demo
Leverages Cloudflare Workers as a hosting platform for the MCP server, supporting features like browser rendering for screenshots and image extraction (for paid accounts)
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Workers MCP Demogenerate an image of a futuristic city skyline at sunset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Demo
这是一个使用 Cloudflare Workers MCP 创建自定义 AI 工具的简单演示项目,这些工具可以与 Claude、Cursor 和其他支持 MCP 的 AI 助手一起使用。
什么是 MCP?
MCP (Model Context Protocol) 是由 Anthropic 开源的一个标准,用于连接 AI 助手与数据源,包括内容仓库、业务工具和开发环境。它的目标是帮助前沿模型生成更好、更相关的回应。
本项目利用 Cloudflare Workers MCP 创建自定义工具,这些工具可以被 AI 助手访问和使用,从而扩展 AI 的能力。
Related MCP server: Remote MCP Server Authless
特点
在 Cloudflare Workers 上运行的自定义 AI 工具
与 Claude、Cursor 和其他 MCP 客户端的无缝集成
能够通过自己的无服务器函数扩展 AI 能力
前提条件
设置步骤
1. 克隆此仓库
git clone https://github.com/akazwz/workers-mcp-demo.git
cd workers-mcp-demo2. 安装依赖
pnpm install3. 配置你的 Cloudflare Worker
确保你已经通过 Wrangler 登录到 Cloudflare:
pnpx wrangler login然后运行 MCP 设置命令:
npx workers-mcp setup这将自动配置你的 Worker 以支持 MCP。
免费用户配置注意事项
如果你是 Cloudflare Workers 的免费用户(非付费用户),需要修改 wrangler.jsonc 文件,删除或注释掉以下配置:
"browser": {
"binding": "BROWSER"
}这是因为 Browser Rendering API 仅适用于付费用户。删除此配置后,screenshotURL 和 extractImagesFromURL 功能将无法使用,但其他功能仍然可以正常工作。
4. 部署你的 Worker
pnpm run deploy5. 配置你的 MCP 客户端
对于 Claude Desktop:
运行以下命令在 Claude 中安装你的 MCP 服务器:
pnpx workers-mcp install:claude对于 Cursor:
在 Cursor 的 MCP 配置中添加以下内容:
{
"type": "command",
"command": "/path/to/workers-mcp run workers-mcp-demo https://your-worker-url.workers.dev /path/to/workers-mcp-demo"
}使用方法
配置完成后,你可以直接从 AI 助手使用你的自定义 MCP 工具。例如,在 Claude Desktop 中,你可以使用如下命令:
@workers-mcp-demo getRandomNumber可用工具
此演示包括以下工具:
getRandomNumber:生成一个随机数generateImage:根据文本提示创建图像screenshotURL:对指定 URL 进行截图(需要付费账户)extractImagesFromURL:从网页中提取图像(需要付费账户)
自定义
要添加自己的工具,编辑 src/index.ts 文件并向 Worker 类添加新方法。更改后,使用以下命令重新部署你的 Worker:
pnpm run deploy故障排除
如果你的 AI 助手看不到你的工具,尝试重启助手。
如果你更改了方法名称或参数,你需要重启 AI 助手才能使更改生效。
检查 Cloudflare Workers 日志以查看部署中的任何错误。
如果使用免费账户时出现
Error: Browser Rendering API is only available for Workers Paid plans错误,请参考上面的免费用户配置注意事项。
许可证
本项目采用 MIT 许可证。
致谢
Cloudflare Workers MCP 提供底层框架
Anthropic Model Context Protocol 开源的 MCP 标准
Cloudflare Workers 提供无服务器平台
Available Tools
2 toolsget_current_dateB
获取当前日期, 如果用户没有提供日期, 则返回当前日期, 如果用户提供的是相对单位, 如前天, 昨天, 明天, 则返回相对单位后的日期
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | 日期 比如2025-05-29 或者 前天 昨天 明天 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It describes the core behavior (returning current date or calculating relative dates) but lacks important details: format of returned date, timezone handling, error behavior for invalid inputs, or whether this is a read-only operation. The description doesn't disclose these behavioral traits.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately concise with two sentences that efficiently explain the tool's functionality. It's front-loaded with the main purpose and follows with usage details. There's no wasted text, though it could be slightly more structured for clarity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has no annotations and no output schema, the description is incomplete. It doesn't explain the return format (e.g., date string structure), error handling, or timezone considerations. For a date-handling tool with 1 parameter, more contextual details are needed to ensure proper agent usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the parameter 'date' clearly documented in the schema. The description adds some semantic context by explaining the two types of inputs (absolute dates like 2025-05-29 and relative units like yesterday), which complements the schema. However, it doesn't provide additional syntax or format details beyond what the schema already states.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '获取当前日期' (get current date) and explains it returns the current date or calculates relative dates like yesterday/tomorrow. It distinguishes from sibling 'get_current_weather' by focusing on dates rather than weather. However, it doesn't explicitly contrast with the sibling tool in the description text itself.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context: when users need current date or relative date calculations. It mentions handling both absolute dates (e.g., 2025-05-29) and relative units (e.g., yesterday). However, it doesn't provide explicit guidance on when to use this vs. alternatives or any exclusion criteria.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_current_weatherC
Get weather info for a given city.
| Name | Required | Description | Default |
|---|---|---|---|
| city | Yes | 城市名称, 比如北京 上海 广州 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It mentions 'Get weather info' which implies a read-only operation, but doesn't disclose any behavioral traits like rate limits, error conditions, data freshness, or what 'weather info' includes (e.g., temperature, humidity). This leaves significant gaps for an agent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary elaboration.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'weather info' includes, potential errors, or any operational constraints. For a tool with one parameter but undefined output and behavior, this leaves too much ambiguity for reliable agent use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the parameter 'city' fully documented in the schema. The description adds no additional meaning beyond implying the tool requires a city input, so it meets the baseline of 3 where the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Get') and resource ('weather info') with a specific scope ('for a given city'), making the purpose unambiguous. However, it doesn't explicitly differentiate from the sibling tool 'get_current_date', though the distinction is obvious from the names.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives or any contextual prerequisites. The description simply states what it does without indicating any constraints, dependencies, or comparison with the sibling tool beyond the obvious domain difference.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v1.0.0- First observed
get_current_date - First observed
get_current_weather
TDQS
Scored across 2 tools
The two tools have completely distinct purposes: get_current_date handles date retrieval and relative date calculations, while get_current_weather provides weather information for cities. There is no overlap in functionality, making it impossible to confuse them.
Both tools follow a consistent 'get_current_' prefix pattern with a descriptive noun suffix (date, weather). This clear and uniform naming convention makes the tools easily identifiable and predictable.
With only two tools, the server feels extremely thin and under-scoped for a general-purpose demo. While each tool is functional, the set lacks breadth, suggesting it might be incomplete or overly narrow for practical agent use.
Given the server's name 'Workers MCP Demo', which implies a broader utility or demo purpose, the toolset is severely incomplete. It covers only date and weather queries, missing many common demo functionalities like data processing, API testing, or other utility operations.
Maintenance
Related MCP Connectors
Cloudflare Workers MCP server: ai-model-router
Cloudflare Workers MCP server: ai-agent-scratchpad
Cloudflare Workers MCP server: ai-gateway
Cloudflare Workers MCP server: ai-token-counter
Related MCP Servers
- FlicenseNot gradedqualityFmaintenanceA Cloudflare Workers implementation of Model Context Protocol (MCP) server that enables AI tools to be exposed to Claude and other assistants through OAuth authentication.14 npm-
- FlicenseNot gradedqualityCmaintenanceA deployable authentication-free MCP (Model Context Protocol) server on Cloudflare Workers that allows you to add custom tools and connect to AI clients like Claude Desktop or Cloudflare AI Playground.-
- FlicenseNot gradedqualityDmaintenanceA Cloudflare Workers-based implementation of Model Context Protocol (MCP) server with OAuth login that allows tools like Claude to access external capabilities.-
- FlicenseNot gradedqualityCmaintenanceA serverless MCP (Model Context Protocol) implementation that can be deployed on Cloudflare Workers without authentication, allowing clients like Claude Desktop to connect to custom AI tools.-