The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as Alchemy from "alchemy"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | |
| 5 | export default Alchemy.Stack( |
| 6 | "CloudflareAgentsExample", |
| 7 | { |
| 8 | providers: Cloudflare.providers(), |
| 9 | state: Cloudflare.state(), |
| 10 | }, |
| 11 | Effect.gen(function* () { |
| 12 | const site = yield* Cloudflare.Website.Vite("Website", { |
| 13 | main: "./src/server.ts", |
| 14 | compatibility: { |
| 15 | date: "2026-06-11", |
| 16 | flags: ["nodejs_compat"], |
| 17 | }, |
| 18 | memo: { |
| 19 | include: ["src/**", "public/**", "index.html", "package.json", "vite.config.ts"], |
| 20 | }, |
| 21 | assets: { |
| 22 | notFoundHandling: "single-page-application", |
| 23 | // Agent and MCP requests reach the Worker even when they accept HTML. |
| 24 | runWorkerFirst: ["/agents/*", "/mcp", "/mcp/*"], |
| 25 | }, |
| 26 | env: { |
| 27 | // `routeAgentRequest` maps `/agents/counter/:name` to the binding |
| 28 | // named after the class. |
| 29 | Counter: Cloudflare.DurableObject("Counter", { className: "Counter" }), |
| 30 | // `McpAgent.serve()` binds its Durable Object as `MCP_OBJECT`. |
| 31 | MCP_OBJECT: Cloudflare.DurableObject("Calculator", { className: "Calculator" }), |
| 32 | }, |
| 33 | }); |
| 34 | |
| 35 | return { |
| 36 | url: site.url, |
| 37 | }; |
| 38 | }), |
| 39 | ); |