Building MCP Server On Cloudflare
CommandCodeAI/agent-skills
Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.
Build, debug, or review Cloudflare Agents SDK applications using the agents package.
$ npx skills add cloudflare/skills --skill agents-sdk -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install cloudflare/skills agents-sdk --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/agents-sdk .claude/skills/agents-sdk && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "agents-sdk" agent skill from https://github.com/cloudflare/skills/tree/main/skills/agents-sdk into .claude/skills/agents-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agents-sdk", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/cloudflare/skills/tree/main/skills/agents-sdkType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add cloudflare/skills --skill agents-sdk -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install cloudflare/skills agents-sdk --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/agents-sdk .agents/skills/agents-sdk && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "agents-sdk" agent skill from https://github.com/cloudflare/skills/tree/main/skills/agents-sdk into .agents/skills/agents-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agents-sdk", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add cloudflare/skills --skill agents-sdk -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install cloudflare/skills agents-sdk --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/agents-sdk .cursor/skills/agents-sdk && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "agents-sdk" agent skill from https://github.com/cloudflare/skills/tree/main/skills/agents-sdk into .cursor/skills/agents-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agents-sdk", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/cloudflare/skills.git --path skills/agents-sdk--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add cloudflare/skills --skill agents-sdk -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install cloudflare/skills agents-sdk --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/agents-sdk .gemini/skills/agents-sdk && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "agents-sdk" agent skill from https://github.com/cloudflare/skills/tree/main/skills/agents-sdk into .gemini/skills/agents-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agents-sdk", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install cloudflare/skills agents-sdkInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add cloudflare/skills --skill agents-sdk -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/agents-sdk .github/skills/agents-sdk && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "agents-sdk" agent skill from https://github.com/cloudflare/skills/tree/main/skills/agents-sdk into .github/skills/agents-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agents-sdk", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add cloudflare/skills --skill agents-sdk -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install cloudflare/skills agents-sdk --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/agents-sdk .opencode/skills/agents-sdk && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "agents-sdk" agent skill from https://github.com/cloudflare/skills/tree/main/skills/agents-sdk into .opencode/skills/agents-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agents-sdk", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
agents-sdkBuild, debug, or review Cloudflare Agents SDK applications using the agents package.
Agents SDK is an agent skill from cloudflare/skills, published by the product's own GitHub organization. Build, debug, or review Cloudflare Agents SDK applications using the agents package.
Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 20 other files, including reference files (for example `references/browse-the-web.md`, `references/callable.md` and `references/client-sdk.md`).
It sits in Agent Workflows, covering MCP servers. It works with Cloudflare, Cloudflare Workers and Model Context Protocol. The repository describes itself as: Skills for teaching agents how to build on Cloudflare. The licence is Apache-2.0.
Read from SKILL.md and the folder at commit 41e0d19. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmFrom the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
developers.cloudflare.comgithub.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Agents SDK loads about 3k tokens when it runs, and up to ~12k if it reads all its reference files. Until then it costs about 24 tokens; SKILL.md has 685 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from cloudflare/skills at commit 41e0d19, republished under its Apache-2.0 licence (© cloudflare). 685 words, ~3,003 tokens.
.claude/skills/agents-sdk/SKILL.md (or your agent's skills folder). This skill also uses 19 other files; get the full folder from GitHub.Your knowledge of the Agents SDK may be outdated. Prefer retrieval over pre-training for any Agents SDK task.
Cloudflare docs: https://developers.cloudflare.com/agents/index.md
| Topic | Docs URL | Use for |
|---|---|---|
| Getting started | Quick start | First agent, project setup |
| Adding to existing project | Add to existing project | Install into existing Workers app |
| Configuration | Configuration | wrangler.jsonc, bindings, assets, deployment |
| Agent class | Agents API | Agent lifecycle, patterns, pitfalls |
| State | Store and sync state | setState, validateStateChange, persistence |
| Routing | Routing | URL patterns, routeAgentRequest |
| Callable methods | Callable methods | @callable, RPC, streaming, timeouts |
| Scheduling | Schedule tasks | schedule(), scheduleEvery(), cron |
| Workflows | Run workflows | AgentWorkflow, durable multi-step tasks |
| HTTP/WebSockets | WebSockets | Lifecycle hooks, hibernation |
| Chat agents | Chat agents | AIChatAgent, streaming, tools, persistence |
| Client SDK | Client SDK | useAgent, AgentClient, state, RPC, HTTP |
| Client tools | Client tools | Client-side tools, autoContinueAfterToolResult |
| Server-driven messages | Autonomous responses | saveMessages, waitUntilStable, server-initiated turns |
| Resumable streaming | Chat agents | Stream recovery on disconnect |
| Email routing, secure reply resolver | ||
| MCP client | MCP client | Connecting to MCP servers |
| MCP server | MCP server | Building MCP servers with createMcpHandler |
| MCP transports | MCP transports | Streamable HTTP, SSE, RPC transport options |
| Securing MCP servers | Securing MCP | OAuth, proxy MCP, hardening |
| Human-in-the-loop | Human-in-the-loop | Workflow approvals, elicitation, timeout handling |
| Durable execution | Durable execution | runFiber(), stash(), surviving DO eviction |
| Queue | Queue | Built-in FIFO queue, queue() |
| Retries | Retries | this.retry(), backoff/jitter |
| Observability | Observability | Diagnostics-channel events |
| Push notifications | Push notifications | Web Push + VAPID from agents |
| Webhooks | Webhooks | Receiving external webhooks |
| Cross-domain auth | Cross-domain auth | WebSocket auth, tokens, CORS |
| Readonly connections | Readonly | shouldConnectionBeReadonly |
| Voice | Voice | Experimental STT/TTS, withVoice |
| Browse the web | Browser tools | Experimental CDP browser automation |
| Think | Think | Experimental higher-level chat agent class |
| Migrations | AI SDK v5, AI SDK v6 | Upgrading @cloudflare/ai-chat |
The Agents SDK provides:
setState@callable() methods invoked over WebSocketscheduleEvery), and cron tasksAgentWorkflowrunFiber() / stash() for work that survives DO evictionqueue()this.retry() with exponential backoff and jittercreateMcpHandlerAIChatAgent with resumable streams, message persistence, toolssaveMessages, waitUntilStable for proactive agent turnsuseAgent, useAgentChat for client appsdiagnostics_channel events for state, RPC, schedule, lifecycle@cloudflare/voiceagents/browser@cloudflare/thinknpm ls agents # Should show agents packageIf not installed:
npm install agentsFor chat agents:
npm install agents @cloudflare/ai-chat ai @ai-sdk/react{
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [{ "name": "MyAgent", "class_name": "MyAgent" }]
},
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyAgent"] }]
}Gotchas:
experimentalDecorators in tsconfig (breaks @callable)"ai": { "binding": "AI" } for Workers AIimport { Agent, routeAgentRequest, callable } from "agents";
type State = { count: number };
export class Counter extends Agent<Env, State> {
initialState = { count: 0 };
validateStateChange(nextState: State, source: Connection | "server") {
if (nextState.count < 0) throw new Error("Count cannot be negative");
}
onStateUpdate(state: State, source: Connection | "server") {
console.log("State updated:", state);
}
@callable()
increment() {
this.setState({ count: this.state.count + 1 });
return this.state.count;
}
}
export default {
fetch: (req, env) => routeAgentRequest(req, env) ?? new Response("Not found", { status: 404 })
};Requests route to /agents/{agent-name}/{instance-name}:
| Class | URL |
|---|---|
Counter | /agents/counter/user-123 |
ChatRoom | /agents/chat-room/lobby |
Client: useAgent({ agent: "Counter", name: "user-123" })
Custom routing: use getAgentByName(env.MyAgent, "instance-id") then agent.fetch(request).
| Task | API |
|---|---|
| Read state | this.state.count |
| Write state | this.setState({ count: 1 }) |
| SQL query | this.sql`SELECT * FROM users WHERE id = ${id}` |
| Schedule (delay) | await this.schedule(60, "task", payload) |
| Schedule (cron) | await this.schedule("0 * * * *", "task", payload) |
| Schedule (interval) | await this.scheduleEvery(30, "poll") |
| RPC method | @callable() myMethod() { ... } |
| Streaming RPC | @callable({ streaming: true }) stream(res) { ... } |
| Start workflow | await this.runWorkflow("ProcessingWorkflow", params) |
| Durable fiber | await this.runFiber("name", async (ctx) => { ... }) |
| Enqueue work | this.queue("handler", payload) |
| Retry with backoff | await this.retry(fn, { maxAttempts: 5 }) |
| Broadcast to clients | this.broadcast(message) |
| Get connections | this.getConnections(tag?) |
Read client-sdk.md for client selection and current connection examples. For chat UI and tools, also read streaming-chat.md.
getAgentByNameuseAgent, useAgentChat, AgentClientsaveMessagesneedsApprovalrunFiber, stash, surviving eviction@cloudflare/think higher-level chat agent@cloudflare/voice STT/TTS© cloudflare, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 19 other files (references) in skills/agents-sdk of cloudflare/skills.
Open the folder on GitHubat commit 41e0d19
We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in cloudflare/skills, which our catalogue first saw on October 7, 2026.
Agents SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Agents SDK this skillcloudflare/skills | 3k | 2 repos | ~3k | Automated safety check: Pass | Apache-2.0 | |
| Building MCP Server On CloudflareCommandCodeAI/agent-skills | 132 | — | ~1.5k | Automated safety check: Pass | MIT | |
| Cloudflare Agentssecondsky/claude-skills | 227 | 1 repos | ~691 | Automated safety check: Pass | MIT | |
| Agents SDKhodgef/apiker | 127 | 3 repos | ~3k | Automated safety check: Pass | MIT | |
| Build MCP Serveranthropics/claude-plugins-official | 37k | 1 repos | ~3k | Automated safety check: Pass | Apache-2.0 | |
| Cloudflare Browser Renderingeinverne/dotfiles | 121 | — | ~4.9k | Automated safety check: Pass | GPL-3.0 |
CommandCodeAI/agent-skills
Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.
secondsky/claude-skills
Build AI agents on Cloudflare Workers with MCP integration, tool use, and LLM providers.
hodgef/apiker
Build AI agents on Cloudflare Workers using the Agents SDK. An agent skill from hodgef/apiker.
anthropics/claude-plugins-official
Entry point for building an MCP server: asks about the use case, picks a deployment model and tool-design pattern, then hands off to more specialized skills.
einverne/dotfiles
Guide for implementing Cloudflare Browser Rendering - a headless browser automation API for screenshots, PDFs, web scraping, and testing.
jumodada/Drissionpage-MCP-Server
A skill your agent uses when testing an authorized Cloudflare Turnstile integration or operating an authorized production challenge with drissionpage-mcp.
cloudflare/skills
Set up, repair, or migrate to Cloudflare Turnstile bot verification in an existing frontend and backend, including server-side Siteverify.
cloudflare/skills
Build, migrate, and deploy Next.js apps on Cloudflare Workers with vinext.
cloudflare/skills
Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.
cloudflare/skills
Build or maintain Cloudflare Sandbox apps on @cloudflare/sandbox@next (SDK 1.0 preview).
cloudflare/skills
Assess and plan migrations from existing VPN, SWG, or SASE platforms to Cloudflare One, including policy mapping, parity gaps, and rollout.
cloudflare/skills
Cloudflare Workers best practices for production applications.
Categories
Build, debug, or review Cloudflare Agents SDK applications using the agents package. Agents SDK is an agent skill from cloudflare/skills, published by the product's own GitHub organization. Build, debug, or review Cloudflare Agents SDK applications using the agents package.
Agents SDK fits situations like: tasks that involve MCP servers.
Run `npx skills add cloudflare/skills --skill agents-sdk -a claude-code`. Or copy the skill folder (skills/agents-sdk in cloudflare/skills) into .claude/skills/agents-sdk in your project. Claude Code loads it when a task matches its description.
Run `npx skills add cloudflare/skills --skill agents-sdk -a codex`. Or copy the skill folder (skills/agents-sdk in cloudflare/skills) into .agents/skills/agents-sdk in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add cloudflare/skills --skill agents-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/agents-sdk, .gemini/skills/agents-sdk, .github/skills/agents-sdk and .opencode/skills/agents-sdk in your project.
Going by SKILL.md and its folder, Agents SDK needs the command-line tools its instructions call (npm). Our summary lists: Node.js.
SKILL.md names 2 domains. As links in the text: developers.cloudflare.com and github.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Agents SDK is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.9k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Agents SDK: Building MCP Server On Cloudflare (CommandCodeAI/agent-skills, 132 stars), Cloudflare Agents (secondsky/claude-skills, 227 stars), Agents SDK (hodgef/apiker, 127 stars) and Build MCP Server (anthropics/claude-plugins-official, 37k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
cloudflare (a GitHub organization, an official publisher) maintains it in cloudflare/skills, which has 2,999 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on October 1, 2026.
Source: cloudflare/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.