Skip to content
VideoIntermediate

Securely Run LLM Generated Code in Cloudflare Sandboxes

How to stop LLM-generated code from stealing your credentials: an MCP-enabled Worker with per-workspace sandboxes, an egress policy and credentials injected from outside the container.

Published
Nov 4, 2026
Watch on YouTube

A walkthrough of an MCP-enabled Cloudflare Worker with three tools — open workspace, run code and close workspace. Each workspace gets its own Durable Object and sandbox container, so an agent can clone a repo, run npm install and retry its scripts in the same isolated environment.

What you’ll learn

  • Give each workspace its own Durable Object and sandbox container
  • Expose open/run/close tools over MCP
  • Lock down outbound traffic with an egress policy
  • Attach GitHub credentials from the Worker, outside the container

Cloudflare products used

Sandbox SDK, Durable Objects, Workers.

Watch the full video on the Cloudflare Developers YouTube channel.

Keep learning