Code Sandbox MCP is a secure sandbox environment for executing code within Docker containers. It provides AI applications with a safe and isolated environment for running code while maintaining security through containerization, offering features like flexible container management, custom environment support, and real-time logging.
Before installing Code Sandbox MCP, ensure you have Docker installed and running:
curl -fsSL https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.sh | bash
# Run in PowerShell
irm https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.ps1 | iex
The installer will:
chmod +x code-sandbox-mcp
Initialize a new compute environment for code execution.
Parameters:
image
(string, optional): Docker image to use as the base environment
Returns:
container_id
that can be used with other tools to interact with this environmentCopy a directory to the sandboxed filesystem.
Parameters:
container_id
(string, required): ID of the container returned from the initialize calllocal_src_dir
(string, required): Path to a directory in the local file systemdest_dir
(string, optional): Path to save the src directory in the sandbox environmentWrite a file to the sandboxed filesystem.
Parameters:
container_id
(string, required): ID of the container returned from the initialize callfile_name
(string, required): Name of the file to createfile_contents
(string, required): Contents to write to the filedest_dir
(string, optional): Directory to create the file in (Default: ${WORKDIR})Execute commands in the sandboxed environment.
Parameters:
container_id
(string, required): ID of the container returned from the initialize callcommands
(array, required): List of command(s) to run in the sandboxed environment
Copy a single file to the sandboxed filesystem.
Parameters:
container_id
(string, required): ID of the container returned from the initialize calllocal_src_file
(string, required): Path to a file in the local file systemdest_path
(string, optional): Path to save the file in the sandbox environmentStop and remove a running container sandbox.
Parameters:
container_id
(string, required): ID of the container to stop and removeDescription: Gracefully stops the specified container with a 10-second timeout and removes it along with its volumes.
A dynamic resource that provides access to container logs.
Resource Path: containers://{id}/logs
MIME Type: text/plain
Description: Returns all container logs from the specified container as a single text resource.
The installer automatically creates the configuration file. If you need to manually configure it:
// ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"code-sandbox-mcp": {
"command": "/path/to/code-sandbox-mcp",
"args": [],
"env": {}
}
}
}
// ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"code-sandbox-mcp": {
"command": "/path/to/code-sandbox-mcp",
"args": [],
"env": {}
}
}
}
// %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"code-sandbox-mcp": {
"command": "C:\\path\\to\\code-sandbox-mcp.exe",
"args": [],
"env": {}
}
}
}
For other AI applications that support MCP servers, configure them to use the code-sandbox-mcp
binary as their code execution backend.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.