Sandbox MCP is a Model Context Protocol (MCP) server that enables LLMs (MCP hosts/clients) to run code in secure, isolated Docker containers.
While LLMs are really good at generating code, most can't run the code they generate. You end up running this untested code directly on your machine, which could have drastic unintended consequences.
Giving LLMs the tools to test the code safely prevents such issues and helps you generate more accurate code in fewer iterations.
Sandbox MCP gives the LLMs an easy-to-use execution environment that anyone can create and configure through a simple, AI-native MCP server that runs locally.
Inspired by Codapi. Some sandboxes are the same as Codapi sandboxes.
This demo shows how Sandbox MCP works with Claude Desktop.
Try the video if the GIF isn't clear.
You can download the appropriate binary for your operating system (for example, Darwin
) and processor architecture (arm64
) from the Releases page (sandbox-mcp_Darwin_arm64.tar.gz
).
Prerequisites:
- Go 1.24 or higher
go install github.com/pottekkat/sandbox-mcp/cmd/sandbox-mcp@latest
Get the path to the sandbox-mcp
binary:
which sandbox-mcp
See the Development section.
Before you use sandbox-mcp
with LLMs, you need to initialize its configuration:
# Create the configuration directory in
# $XDG_CONFIG_HOME/sandbox-mcp and pull
# the default sandboxes from GitHub
sandbox-mcp --pull
# Build the Docker images for the sandboxes
sandbox-mcp --build
Note
Make sure you have Docker installed and running.
Add this to your claude_desktop_config.json
for Claude Desktop or mcp.json
for Cursor IDE:
{
"mcpServers": {
"sandbox-mcp": {
"command": "path/to/sandbox-mcp",
"args": [
"--stdio"
]
}
}
}
Note
Make sure to replace path/to/sandbox-mcp
with the actual path to the sandbox-mcp
binary.
Run shell commands in a Linux environment with strict security and network constraints.
Run Python code with a set of pre-installed libraries.
Important
You can create and add your own sandboxes in $XDG_CONFIG_HOME/sandbox-mcp/sandboxes
. A sandbox is essentially a Dockerfile and a JSON configuration. Check out the examples and the guide to learn more.
Use various network tools in an isolated Linux sandbox. The container has network access.
See jonlabelle/docker-network-tools for a list of available tools.
Run simple Go code in an isolated sandbox.
Run Apache APISIX in a sandbox. Custom routes, plugins, and upstreams can be configured through a YAML file and it can be tested using curl
commands. Has network access.
Run JavaScript code using Node.js.
Fork and clone the repository:
git clone https://github.com/username/sandbox-mcp.git
Change into the directory:
cd sandbox-mcp
Install dependencies:
make deps
Build the project:
make build
Update your MCP servers configuration to point to the local build:
{
"mcpServers": {
"sandbox-mcp": {
"command": "/path/to/sandbox-mcp/dist/sandbox-mcp",
"args": [
"--stdio"
]
}
}
}