AgenticFrameworksMCP

Cloudflare Agents SDK Documentation

by Cloudflare

IntermediateDocumentationFree~4-6 hours to work through the guides, then ongoing reference

Build stateful TypeScript agents that survive restarts — persistent memory, WebSockets, scheduled work and MCP, each on its own Durable Object.

Start LearningAdded Aug 21, 2026 · Updated Aug 21, 2026

Overview

Cloudflare's Agents SDK documentation opens with its own summary — 'Create stateful AI agents with persistent memory, real-time WebSocket connections, and scheduled tasks using the Cloudflare Agents SDK' — and that statefulness is the whole design. Each agent is a TypeScript class extending a base Agent class, and each instance runs on a Durable Object addressed by a stable identifier such as a user ID or ticket number, giving it isolated storage, an embedded SQL database and durable identity across restarts. The docs are organised into Communication Channels (chat, email, voice, Slack, webhooks), the Agent Harness, the Agents SDK Runtime — split into Lifecycle (the Agent class, state, sessions), Communication (routing, WebSockets) and Execution (scheduled tasks, and Fibers for durable execution) — plus Tools (sandboxed code execution, MCP, browser control, AI Search, payments) and Operations (logs, metrics and traces). A 'Code Mode' section covers letting models discover and orchestrate multiple tools by writing code rather than emitting one tool call at a time. The stack is JavaScript/TypeScript on Node 24+, scaffolded with `npm create cloudflare@latest -- --template cloudflare/agents-starter`, and works with Workers AI, OpenAI, Anthropic and Google Gemini. The SDK is developed in the open at github.com/cloudflare/agents under an MIT licence with roughly 5.5k stars and nearly 1,500 commits; note the maintainers state they are not currently accepting external pull requests, though issues and discussions are open.

At a Glance

Topic
Agentic
Level
Intermediate
Format
Documentation
Cost
Free
Duration
~4-6 hours to work through the guides, then ongoing reference
Provider
Cloudflare
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • Model each agent as a Durable Object with its own storage, SQL database and durable identity
  • Persist and synchronize agent state to connected clients without writing your own store
  • Stream agent output over WebSockets and keep chat message history across sessions
  • Schedule future work and resume long-running tasks after a crash using Fibers
  • Expose and consume MCP servers so agents can call external tools safely
  • Run untrusted model-generated code inside a managed sandbox rather than your worker
  • Add human approval steps to workflow orchestration before high-impact actions execute
  • Instrument agents with logs, metrics and traces for production observability

Highlights

  • State is the primitive, not an add-on — persistence, sessions and scheduling come from Durable Objects rather than a bolted-on database
  • The only major agent framework where each agent instance is individually addressable and horizontally scalable by construction
  • TypeScript-first, so a full-stack team can ship an agent and its React UI from one codebase (React hooks and vanilla JS clients ship in the box)
  • Covers channels most SDKs ignore — email, Slack, webhooks and a voice pipeline with STT, TTS and voice activity detection
  • Model-agnostic: Workers AI, OpenAI, Anthropic and Gemini are all first-class
  • Open source under MIT at cloudflare/agents (~5.5k stars), though the team is not taking external pull requests right now

Who It’s For

Best For

  • TypeScript and full-stack engineers building agents that need to hold state between sessions
  • Teams shipping real-time chat, voice or collaborative agent UIs
  • Backend engineers who need long-running or scheduled agent work to survive restarts
  • Developers already on Cloudflare Workers who want to add agents without new infrastructure

Prerequisites

  • Working TypeScript or modern JavaScript, and comfort with npm and Node 24+
  • Basic familiarity with Cloudflare Workers and the idea of edge/serverless execution
  • Understanding of LLM tool calling and, ideally, what MCP is for

FAQ

What is Cloudflare Agents SDK Documentation?

The official documentation for Cloudflare's Agents SDK, a TypeScript framework where every agent instance is a Durable Object: a stateful micro-server with its own storage, SQL database, WebSocket connections and scheduler. It is written for engineers who have built a prototype agent in Python and now need one that keeps state between sessions, resumes long-running work after a crash, and streams to a real UI. You finish able to deploy a persistent, addressable agent to the edge.

Is Cloudflare Agents SDK Documentation free?

Cloudflare Agents SDK Documentation is free to access.

What level is Cloudflare Agents SDK Documentation for?

Cloudflare Agents SDK Documentation is aimed at a intermediate audience. Recommended background: Working TypeScript or modern JavaScript, and comfort with npm and Node 24+, Basic familiarity with Cloudflare Workers and the idea of edge/serverless execution, Understanding of LLM tool calling and, ideally, what MCP is for.

How long does Cloudflare Agents SDK Documentation take?

Expect roughly ~4-6 hours to work through the guides, then ongoing reference. Most learners work through it at their own pace.

What will I learn from Cloudflare Agents SDK Documentation?

You'll learn: Model each agent as a Durable Object with its own storage, SQL database and durable identity; Persist and synchronize agent state to connected clients without writing your own store; Stream agent output over WebSockets and keep chat message history across sessions; Schedule future work and resume long-running tasks after a crash using Fibers; Expose and consume MCP servers so agents can call external tools safely; Run untrusted model-generated code inside a managed sandbox rather than your worker; Add human approval steps to workflow orchestration before high-impact actions execute; Instrument agents with logs, metrics and traces for production observability.

Topics

ai agentscloudflare workersdurable objectstypescript agentsmcpstateful agents

Sources

This page was written from 2 sources, 1 on domains other than developers.cloudflare.com.

  1. 1.developers.cloudflare.comagentsvendor
  2. 2.github.comagents