Skip to main content
The Claude Agent SDK is Anthropic’s framework for building agents with tool-use loops. Expose sandbox.commands.run as an in-process MCP tool so every command the agent generates runs in an isolated VM instead of on your machine.

Setup

The agent loop runs on your machine, so the Claude Agent SDK reads ANTHROPIC_API_KEY from your local environment. Only the commands that the agent runs go to the sandbox.

Wire the sandbox into the agent

The highlighted block defines a bash tool backed by the sandbox. Everything else is standard Claude Agent SDK usage.
allowedTools only skips the permission prompt; it does not remove Claude Code’s built-in Bash, Read, and Edit tools. Without tools: [], the agent can run commands on your machine instead of in the sandbox. Add equivalent tools for file reads/writes the same way; see Run commands and Read & write files.