$57
Status: Production Ready ✅ Last Updated: 2025-10-21 Production Tested: Cloudflare's own MCP servers (https://github.com/cloudflare/mcp-server-cloudflare)
cloudflare agentsagents sdkcloudflare agents sdkagents packagenpm create cloudflare agentsnpm i agentsbuild agents cloudflareai agents workersdurable objects agentsstateful agentsAgent class, extend agent, onRequest agent, onConnect agent, onMessage agentuseAgent hook, AgentClient, agentFetch, useAgentChatthis.setState agent, agent state management, state sync agents, this.sql agentthis.schedule, schedule tasks agent, cron agents, agent alarmsrun workflows agent, agent workflows, workflow integration agentsbrowse web agents, puppeteer agents, browser rendering agentsrag agents, vectorize agents, agent embeddings, retrieval augmented generation agentsmcp server, McpAgent, mcp tools, model context protocolrouteAgentRequest, getAgentByName, agent instance, calling agentsAIChatAgent, chat agents, streaming chat agentwebsocket agents, server-sent events agents, sse agentsstateful micro-serverslong-running agentsautonomous agentshuman in the loop agents, hitl agents, approval workflow agentsmulti-agent systems, agent orchestration, agent communicationpersistent agent stateagent with databasescheduled agent tasksagent web scraping"Agent class must extend""new_sqlite_classes""migrations required""binding not found""agent not exported""callback does not exist""state limit exceeded""migration tag""workflow binding missing""browser binding required""vectorize index not found""Cannot enable SQLite on existing class""Migrations are atomic"This skill provides comprehensive knowledge for the Cloudflare Agents SDK - a framework for building AI-powered autonomous agents on Cloudflare Workers + Durable Objects.
Agents can:
Each agent instance is a globally unique, stateful micro-server that can run for seconds, minutes, or hours.
This skill prevents 15+ documented issues:
| Issue | Source | Impact | |-------|---------|---------| | Migrations not atomic | Durable Objects Migrations | Cannot gradually deploy migrations - deployment fails | | Missing new_sqlite_classes | Agents Configuration | Cannot enable SQLite later - must be in v1 migration | | Agent class not exported | Agents API | Binding fails with "Cannot access undefined" | | Binding name mismatch | Configuration | "Binding not found" error | | Global uniqueness not understood | Agents API | Same name = same instance globally (can cause data leakage) | | WebSocket state not persisted | WebSockets | Connection state lost after disconnect | | Scheduled task callback missing | Schedule Tasks | Runtime error: "Method does not exist" | | State size limit exceeded | State Management | Database exceeds 1GB limit | | Task payload too large | Schedule Tasks | Task exceeds 2MB limit | | Workflow binding missing | Run Workflows | Cannot access workflow binding | | Browser binding required | Browse the Web | Puppeteer fails without binding | | Vectorize index not found | RAG | Query fails on non-existent index | | MCP transport confusion | MCP Transport | Using deprecated SSE instead of /mcp | | Authentication bypass | Calling Agents | Security vulnerability | | Instance naming errors | Calling Agents | Cross-user data leakage |
Use this skill when:
Don't use this skill when:
// Create an Agent class
import { Agent } from "agents";
interface Env {
AI: Ai;
}
export class MyAgent extends Agent<Env> {
async onRequest(request: Request): Promise<Response> {
return Response.json({ agent: this.name, state: this.state });
}
async onConnect(connection: Connection, ctx: ConnectionContext) {
connection.send("Welcome!");
}
async onMessage(connection: Connection, message: WSMessage) {
if (typeof message === 'string') {
connection.send(`Echo: ${message}`);
}
}
}
export default MyAgent;
// wrangler.jsonc
{
"durable_objects": {
"bindings": [{"name": "MyAgent", "class_name": "MyAgent"}]
},
"migrations": [
{"tag": "v1", "new_sqlite_classes": ["MyAgent"]}
]
}
Manual Setup (without skill):
With This Skill:
Savings: ~65-70% tokens, 100% error prevention
Complete guide covering all 17 API surfaces:
Production-ready code examples:
wrangler-agents-config.jsonc - Complete configurationbasic-agent.ts - HTTP agent basicswebsocket-agent.ts - Real-time communicationstate-sync-agent.ts - State management + SQLscheduled-agent.ts - Task schedulingworkflow-agent.ts - Workflow integrationbrowser-agent.ts - Web scrapingrag-agent.ts - RAG with Vectorizechat-agent-streaming.ts - Streaming chatcalling-agents-worker.ts - Agent routingreact-useagent-client.tsx - React clientmcp-server-basic.ts - MCP serverhitl-agent.ts - Human-in-the-loopagents - Agents SDK (required)@modelcontextprotocol/sdk - For MCP servers@cloudflare/puppeteer - For web browsingai - AI SDK for model calls@ai-sdk/openai - OpenAI models@ai-sdk/anthropic - Anthropic modelscloudflare-worker-base - Foundation for Workers projectscloudflare-workers-ai - Workers AI modelscloudflare-vectorize - Vector database for RAGcloudflare-d1 - D1 serverless SQLcloudflare-r2 - R2 object storageMaintained by: Jeremy Dawes (Jezweb) License: MIT Last Verified: 2025-10-21
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer