Sandbox any MCP server in Claude Code with one line
An MCP server is a program you hand to your agent and let run on your machine, with your user's permissions. Most are fine. If one is buggy or compromised, it can read your SSH keys or call out to any host. Anthropic's Sandbox Runtime ( srt ) wraps any process in OS-level file and network limits, no container needed. Here is the setup with the real commands. The short version lives on the Deduped…
An MCP server is a program handed to an agent to run on your machine, with your user's permissions. However, if the server is buggy or compromised, it could access your SSH keys or contact any host. Anthropic's Sandbox Runtime (srt) limits any process by applying OS-level file and network restrictions, without requiring a container.
To set up srt, install it with "npm install -g @anthropic-ai/sandbox-runtime". Before using it, you can test it by running "srt curl anthropic.com" which should succeed. "srt curl example.com" will block the connection due to the network allowlist, and "srt cat ~/.ssh/id_rsa" will fail with "Operation not permitted".
To wrap an MCP server, change the command from "npx" to "srt" and keep the old command in the args array. Then, create a settings file (~/.srt-settings.json) to define the file and network permissions. Set "denyRead" as an empty array, "allowWrite" to allow writes to the current directory, and "denyWrite" to deny writes to a sensitive folder. For network, set "allowedDomains" as an empty array to block all network access, and add any necessary hostnames to "deniedDomains".
Be aware that if the settings file is empty or invalid, srt will exit with an error instead of falling back to default settings. Keep secrets out of the allowed folders and limit your allowlist. Windows support is newer and has known limitations, so read the README's Windows section. For additional risk reduction, refer to the GitHub MCP server walkthrough.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.