An interactive demo application showcasing every feature 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, recurring, and cron-based 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 |
|---|---|
| Supervisor | Manager-child agent pattern using getAgentByName() for RPC |
| Chat Rooms | Lobby with room agents for multi-user chat |
| Workers | Fan-out parallel processing (documentation) |
| Pipeline | Chain of responsibility pattern (documentation) |
| Demo | Description |
|---|---|
| Chat | AIChatAgent with message persistence and streaming |
| Tools | Client-side tool execution with confirmation flows |
| Codemode | AI code generation and editing |
| Demo | Description |
|---|---|
| Server | Creating MCP servers with tools, resources, and prompts |
| Client | Connecting to external MCP servers |
| OAuth | OAuth authentication for MCP connections |
| 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.
playground/
├── src/
│ ├── demos/ # Demo pages and agent definitions
│ │ ├── core/ # State, callable, streaming, schedule, etc.
│ │ ├── ai/ # Chat, tools, codemode
│ │ ├── mcp/ # Server, client, OAuth
│ │ ├── multi-agent/ # Supervisor, chat rooms, workers, pipeline
│ │ ├── workflow/ # Basic, approval
│ │ └── email/ # Receive, secure replies
│ ├── 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, Dark, and System themes.