Cloudflare: Agents SDK#
Deploys an app built on Cloudflare's Agents SDK
with Cloudflare.Website.Vite. vite.config.ts is the Agents starter's,
unchanged: agents() compiles the @callable() decorators.
src/server.ts defines two agents, each a Durable Object declared in
alchemy.run.ts:
Counter, a statefulAgent. Its state syncs to connected clients,@callable()methods run over its WebSocket,schedule()calls it back later, andonRequestanswers plain HTTP.routeAgentRequestserves it at/agents/counter/:name, through the binding named after the class.Calculator, anMcpAgentMCP server with anaddtool, served at/mcpthrough theMCP_OBJECTbindingMcpAgent.serve()expects.
src/client.tsx is a React client that connects with useAgent.
Deploy#
bun run deploy
Develop#
bun run dev
Destroy#
bun run destroy