An interactive demo application showcasing the major feature areas of the Cloudflare Agents SDK. Use it to learn the SDK, test features, and understand how agents work.
# Install dependencies
npm install
# Start the development server
npm startVisit http://localhost:5173 to explore the playground.
The playground is organized into feature categories, each with interactive demos:
| Demo | Description |
|---|---|
| State | Real-time state synchronization with setState() and onStateChanged() |
| Callable | RPC methods using the @callable decorator |
| Streaming | Streaming responses with StreamingResponse |
| Schedule | One-time and recurring task scheduling |
| Connections | WebSocket lifecycle, client tracking, and broadcasting |
| SQL | Direct SQLite queries using this.sql template literal |
| Routing | Agent naming strategies (per-user, shared, per-session) |
| Readonly | Read-only agent access |
| Retry | Retry with backoff and shouldRetry |
| Demo | Description |
|---|---|
| Fibers | Long-running work with checkpoints and recovery hooks |
| Demo | Description |
|---|---|
| Supervisor | Manager-child agent pattern using getAgentByName() for RPC |
| Chat Rooms | Lobby with room agents for multi-user chat |
| Workers | Fan-out parallel processing |
| Pipeline | Chain of responsibility pattern |
| Demo | Description |
|---|---|
| Chat | AIChatAgent with message persistence and streaming |
| Tools | Client-side tool execution with confirmation flows |
| Codemode | AI code generation and editing |
| Agent Tools | Delegate chat work to child agents with inline timelines |
| Think + Shell | Assistant runtime with durable workspace and state tools |
| Demo | Description |
|---|---|
| Server | Creating MCP servers with tools, resources, and prompts |
| Client | Connecting to external MCP servers |
| OAuth | OAuth authentication for MCP connections |
| Advanced MCP | Transports, elicitation, codemode, and x402 patterns |
| Demo | Description |
|---|---|
| Basic | Interactive multi-step workflow simulation with progress |
| Approval | Human-in-the-loop approval/rejection patterns |
| Demo | Description |
|---|---|
| Receive | Receive real emails via Cloudflare Email Routing |
| Secure Replies | Send HMAC-signed replies for secure routing back to the agent |
Note: Email demos require deployment to Cloudflare. A warning banner is shown when running locally.
| Demo | Description |
|---|---|
| Integration Stories | Email, webhooks, push, A2A, x402, and browser-tool stories |
playground/
├── src/
│ ├── demos/ # Demo pages and agent definitions
│ │ ├── core/ # State, callable, streaming, schedule, etc.
│ │ ├── ai/ # Chat, tools, codemode
│ │ ├── durable/ # Fibers and durable execution
│ │ ├── mcp/ # Server, client, OAuth
│ │ ├── multi-agent/ # Supervisor, chat rooms, workers, pipeline
│ │ ├── workflow/ # Basic, approval
│ │ ├── email/ # Receive, secure replies
│ │ └── integrations/ # Product integration explainers
│ ├── components/ # Shared UI components
│ ├── layout/ # App layout (sidebar, wrapper)
│ ├── hooks/ # React hooks (theme, userId, logs)
│ ├── pages/ # Home page
│ ├── client.tsx # Client entry point
│ ├── server.ts # Worker entry point
│ └── styles.css # Tailwind styles
├── testing.md # Manual testing guide
├── TODO.md # Planned improvements
└── wrangler.jsonc # Cloudflare configuration
See testing.md for a comprehensive guide on manually testing every feature.
Each demo has its own Durable Object agent. The full list of agents and workflows is defined in wrangler.jsonc.
For the email demos, set EMAIL_SECRET for HMAC-signed replies:
# Production
wrangler secret put EMAIL_SECRETFor local development, add it to a .env file:
EMAIL_SECRET=your-secret-for-email-signing
To test the email demos with real emails:
- Deploy to Cloudflare:
npm run deploy - Go to Cloudflare Dashboard → Email → Email Routing
- Add a routing rule to forward emails to your Worker
- Send emails to:
receive+instanceId@yourdomain.com→ ReceiveEmailAgentsecure+instanceId@yourdomain.com→ SecureEmailAgent
Click the theme toggle in the sidebar footer to switch between Light and Dark themes.