Cloudflare Agents
Last Updated: 2025-11-21
Quick Start
export default {
async fetch(request, env, ctx) {
const agent = {
tools: [
{ name: 'getTodo', handler: async ({id}) => ({id, title: 'Task'}) }
],
async run(input) {
return await processWithLLM(input, this.tools);
}
};
return Response.json(await agent.run(await request.text()));
}
};
Core Features
- Tool Integration: Register and execute tools
- LLM Providers: OpenAI, Anthropic, Google Gemini
- MCP Protocol: Model Context Protocol support
- Cloudflare Bindings: D1, KV, R2, Durable Objects
Agent Pattern
const agent = {
tools: [...],
systemPrompt: 'You are a helpful assistant',
model: 'gpt-4o',
async run(input) {
// Process with LLM
}
};
Resources
Core Documentation
references/patterns-concepts.md (317 lines) - What is Cloudflare Agents, patterns & concepts, critical rules, known issues prevention
references/configuration-guide.md (152 lines) - Complete configuration deep dive
references/agent-api.md (115 lines) - Complete Agent Class API reference
Integration Guides
references/http-sse-guide.md (74 lines) - HTTP & Server-Sent Events
references/websockets-guide.md (110 lines) - WebSocket integration
references/state-management.md (388 lines) - State management, scheduled tasks, workflows
references/mcp-integration.md (130 lines) - Model Context Protocol integration
Advanced Features
references/advanced-features.md (637 lines) - Browser automation, RAG, AI model integration, calling agents, client APIs
Error Reference
references/error-catalog.md (10 lines) - Common errors and solutions
Templates
templates/basic-agent.ts - Basic agent setup
templates/browser-agent.ts - Browser automation
templates/calling-agents-worker.ts - Calling other agents
templates/chat-agent-streaming.ts - Streaming chat agent
templates/hitl-agent.ts - Human-in-the-loop
templates/mcp-server-basic.ts - MCP server integration
templates/rag-agent.ts - RAG implementation
templates/react-useagent-client.tsx - React client integration
templates/scheduled-agent.ts - Scheduled tasks
templates/state-sync-agent.ts - State synchronization
templates/websocket-agent.ts - WebSocket agent
templates/workflow-agent.ts - Workflows integration
templates/wrangler-agents-config.jsonc - Wrangler configuration
Official Docs: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-agents/
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: cloudflare-agents3description: Build AI agents on Cloudflare Workers with MCP integration, tool use, and LLM providers. Use when this capability is needed.4---56# Cloudflare Agents78**Last Updated**: 2025-11-21910## Quick Start1112```typescript13export default {14 async fetch(request, env, ctx) {15 const agent = {16 tools: [17 { name: 'getTodo', handler: async ({id}) => ({id, title: 'Task'}) }18 ],19 async run(input) {20 return await processWithLLM(input, this.tools);21 }22 };23 24 return Response.json(await agent.run(await request.text()));25 }26};27```2829## Core Features3031- **Tool Integration**: Register and execute tools32- **LLM Providers**: OpenAI, Anthropic, Google Gemini33- **MCP Protocol**: Model Context Protocol support34- **Cloudflare Bindings**: D1, KV, R2, Durable Objects3536## Agent Pattern3738```typescript39const agent = {40 tools: [...],41 systemPrompt: 'You are a helpful assistant',42 model: 'gpt-4o',43 async run(input) {44 // Process with LLM45 }46};47```4849## Resources5051### Core Documentation52- `references/patterns-concepts.md` (317 lines) - What is Cloudflare Agents, patterns & concepts, critical rules, known issues prevention53- `references/configuration-guide.md` (152 lines) - Complete configuration deep dive54- `references/agent-api.md` (115 lines) - Complete Agent Class API reference5556### Integration Guides57- `references/http-sse-guide.md` (74 lines) - HTTP & Server-Sent Events58- `references/websockets-guide.md` (110 lines) - WebSocket integration59- `references/state-management.md` (388 lines) - State management, scheduled tasks, workflows60- `references/mcp-integration.md` (130 lines) - Model Context Protocol integration6162### Advanced Features63- `references/advanced-features.md` (637 lines) - Browser automation, RAG, AI model integration, calling agents, client APIs6465### Error Reference66- `references/error-catalog.md` (10 lines) - Common errors and solutions6768### Templates69- `templates/basic-agent.ts` - Basic agent setup70- `templates/browser-agent.ts` - Browser automation71- `templates/calling-agents-worker.ts` - Calling other agents72- `templates/chat-agent-streaming.ts` - Streaming chat agent73- `templates/hitl-agent.ts` - Human-in-the-loop74- `templates/mcp-server-basic.ts` - MCP server integration75- `templates/rag-agent.ts` - RAG implementation76- `templates/react-useagent-client.tsx` - React client integration77- `templates/scheduled-agent.ts` - Scheduled tasks78- `templates/state-sync-agent.ts` - State synchronization79- `templates/websocket-agent.ts` - WebSocket agent80- `templates/workflow-agent.ts` - Workflows integration81- `templates/wrangler-agents-config.jsonc` - Wrangler configuration8283**Official Docs**: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-agents/8485---86> Converted and distributed by [TomeVault](https://tomevault.io/claim/secondsky) — claim your Tome and manage your conversions.87<!-- tomevault:4.0:skill_md:2026-04-11 -->