Cloudflare Agents SDK (agents)

September 1, 2026 ยท View on GitHub

This repo has the Cloudflare Agents SDK installed as the agents npm package. It is designed for building long-lived, stateful "agent instances" on top of Durable Objects (with built-in state, SQLite, WebSockets, queues, scheduling, Workflows integration, MCP, and more).

Primary docs:

The installed version is pinned in packages/worker/package.json.

Quick pointers for this repo

  • MCP HTTP /mcp is served by origin (packages/worker/src/index.ts via MCP.serve(...)). The MCP Durable Object class (McpAgent in packages/worker/src/mcp/index.ts) is owned by kody-platform.
  • Capabilities exposed through the compact search / execute tools are registered per-domain (packages/worker/src/mcp/capabilities/*/domain.ts) and merged in packages/worker/src/mcp/capabilities/builtin-domains.ts; see adding capabilities.
  • This project is not organized around the React hook APIs from the SDK; for non-React clients, use AgentClient from agents/client.

Required configuration (Durable Objects + SQLite)

Agents require Durable Objects and (for persisted state) SQLite-backed storage. Cloudflare's setup checklist lives here:

Docs map (what Cloudflare documents)

Use these sections when you want the official "how/why" and end-to-end guides:

SDK module map (what you can import)

These are the import paths exported by the installed agents package.

Core server-side API

Client SDK (non-React friendly)

MCP (Model Context Protocol)

Use these if you're building MCP servers or connecting to external MCP servers.

Workflows integration

Scheduling prompt/schema helpers

Email helpers

Observability

Payments (x402)

Optional UI/framework integrations

These exist, but you only need them if your UI stack wants them.

  • agents/react (React state sync)

Capability outline (what the SDK enables)

Use this section when you want to answer "can Agents do X?" quickly.

Durable, per-instance state + SQLite

Real-time communication (WebSockets) and streaming (HTTP/SSE)

RPC method calls from clients

Access control: readonly connections

Background work: queues + schedules

Durable, multi-step execution: Workflows

  • Run Cloudflare Workflows from an Agent (this.runWorkflow(...)) and handle progress/completion callbacks. Docs: https://developers.cloudflare.com/agents/api-reference/run-workflows/
  • In Kody runtime code, use workflows.create for durable batch sweeps, migrations, polling loops, or retryable work that may outlive execute's timeout; inspect runs with workflowRunList.

LLM integration (bring your model/provider)

The SDK does not force a single model provider. Common options in the docs:

  • Workers AI bindings and streaming
  • AI Gateway routing
  • Vercel AI SDK (ai, @ai-sdk/*) for a unified provider interface

Docs: https://developers.cloudflare.com/agents/api-reference/using-ai-models/

RAG, Vectorize, and web browsing

MCP (servers and clients)

Email routing

Platform limits + operational notes