Skip to content

Deploy to Cloudflare Sandboxes

The backends/cloudflare/ directory implements the same execution contract as the local compose stack, running on Cloudflare Sandboxes (GA since April 2026). Sessions become Durable Object instances; the same ant beta:worker poll runs inside each one.

Cloudflare Sandboxes require a Workers Paid plan with Containers enabled. Click the button to clone the repository into your connected GitHub or GitLab account, provide the required secrets, and deploy the backend.

Deploy to Cloudflare Workers

  1. Authenticate and install dependencies.

    Terminal window
    cd backends/cloudflare
    bun install
    bunx wrangler login
  2. Add the required Worker secrets. These must be secrets, not plaintext vars — agent tool calls can read the worker environment.

    Terminal window
    bunx wrangler secret put ANTHROPIC_ENVIRONMENT_KEY
    bunx wrangler secret put ANTHROPIC_ENVIRONMENT_ID
    bunx wrangler secret put SANDBOX_API_TOKEN
  3. Deploy.

    Terminal window
    bunx wrangler deploy

    The wrangler.jsonc instance_type defaults to lite. Raise it to a larger instance type if sessions require more memory or CPU.

Once deployed, start the Anthropic worker inside a sandbox by posting to the session endpoint:

Terminal window
curl -X POST "https://claude-sandbox-cf.<your-subdomain>.workers.dev/sessions/<random-session-id>/ant" \
-H "Authorization: ******"

MCP servers running inside the sandbox are reachable through the SDK’s native cloudflared quick tunnel; see sandbox.tunnels.get(port) in the Worker source.

Both backends implement the same contract. See the architecture explanation for a comparison.