
Cloudflare Agents SDK
Build stateful, globally distributed AI agents on Durable Objects — chat, scheduling, MCP, and email included.
About
The Cloudflare Agents SDK (agents on npm) is the framework for building AI agents that live on Cloudflare's edge. Each agent is a Durable Object with its own persistent state, storage, and lifecycle: it hibernates when idle and wakes on demand, syncs state to connected clients over WebSockets, and runs close to users worldwide.
Three base classes cover the common shapes: Agent for custom state, RPC, scheduling, queues, SQL, and email; AIChatAgent (via @cloudflare/ai-chat) for streaming chat with automatic message persistence and resumable streams; and McpAgent for exposing your agent as an MCP server. Scheduling supports one-off, delayed, and cron tasks, @callable exposes type-safe RPC methods, and newer additions include Workflows integration for durable multi-step tasks with human-in-the-loop approval, plus an experimental Code Mode where the LLM writes executable TypeScript instead of individual tool calls. The SDK is open source (MIT, 5,800+ stars, pushed this week); running it at scale means running on Cloudflare's platform.
What it can do
- Stateful agents on Durable Objects with SQLite persistence and hibernation
- `Agent`, `AIChatAgent`, and `McpAgent` base classes
- WebSocket state sync, type-safe RPC via `@callable`, scheduling and cron
- MCP server and client support; email receive/respond via Email Routing
- Durable Workflows with human-in-the-loop approval
- React hooks (`useAgent`, `useAgentChat`) and vanilla JS client
Setup
- Run
npm install agents(plus@cloudflare/ai-chatfor chat agents). - Scaffold with
npm create cloudflare@latest -- --template cloudflare/agents-starter. - Declare Durable Object bindings and SQLite migrations in
wrangler.jsonc. - Extend
AgentorAIChatAgent, implement handlers likeonChatMessageoronEmail. - Deploy with
wrangler deploy; useuseAgent/useAgentChatReact hooks on the frontend.
Prerequisites
Node.js; a Cloudflare account with Workers; Wrangler CLI; familiarity with Durable Objects concepts helps.
Use cases
Works with
Trust score — 8/10
Scored 8/10 (metrics tier, metrics-v1). Evidence: 5,836 GitHub stars (GitHub API), MIT license, official Cloudflare repo pushed Oct 15 2026, official docs verified live, community skill references corroborating the API surface. Strengths: genuinely open SDK from a major infrastructure provider, durable-primitive design (state, scheduling, hibernation) that fits agents well. Docked for: (1) production use means Cloudflare lock-in — Durable Objects don't port elsewhere; (2) edge runtime constraints (CPU time, no native modules) limit some agent workloads. License: MIT (SDK); Cloudflare platform terms for hosting.
★ 5,836 GitHub stars
How the trust score is built
Full methodology →- Adoption · stars/downloads, log-scaled vs peers
- 7.0/10
- Maintenance · recency, releases, issue load
- 9.0/10
- Openness · license + docs
- 8.0/10
- Manual review · sanity read + red-flag check
- 8.0/10
- · 5,836 GitHub stars (log-scaled vs catalog peers, verified via GitHub API)
- · last push Oct 15 2026; MIT-licensed official Cloudflare repo; docs verified live at developers.cloudflare.com/agents
- · Agent/AIChatAgent/McpAgent on Durable Objects: state, WebSockets, scheduling, SQL, email, Workflows, Code Mode — API surface corroborated by community skill references
- · manual review: production use means Cloudflare lock-in (Durable Objects don't port); edge runtime constraints (CPU time, no native modules) limit some agent workloads
Sources
Every fact above was checked against these sources. Where a claim comes from the provider and couldn't be independently verified, the text says so.