This project is currently in beta and under active development. Features may change or be incomplete.

MCP Server

Let AI agents manage your sandboxes through the Model Context Protocol.

Overview

Coding Sandbox includes a built-in Model Context Protocol (MCP) server that allows AI agents like Claude, Copilot, and others to create, manage, and interact with sandboxes directly. The MCP server communicates with the local API under the hood.

Prerequisites

The Local API must be enabled in Settings for the MCP server to work. The MCP server talks to the local API on localhost:8090.

Setup

Claude Desktop

Add the following to your Claude Desktop MCP configuration file (claude_desktop_config.json):

claude_desktop_config.json
{
  "mcpServers": {
    "coding-sandbox": {
      "command": "csb",
      "args": ["mcp", "serve"]
    }
  }
}

Restart Claude Desktop after saving. You should see "coding-sandbox" appear in the MCP tools list.

Other MCP Clients

Any MCP-compatible client can connect to the Coding Sandbox server. Start the server manually with:

bash
csb mcp serve

The server uses stdio transport by default. For HTTP transport:

bash
csb mcp serve --transport http --port 3100

Available Tools

Sandbox Tools

list_sandboxes

List all sandboxes with their current status, agent type, and resource usage.

Parameters
{
  "status": "running"  // optional: filter by "running", "stopped", or "all"
}

create_sandbox

Create a new sandbox with a specified agent and configuration.

Parameters
{
  "name": "my-project",       // required: unique sandbox name
  "agent": "claude",          // required: agent type
  "ports": ["3000:3000"],     // optional: port mappings
  "env": {                    // optional: environment variables
    "API_KEY": "..."
  },
  "tunnel": false             // optional: enable tunnel on creation
}

start_sandbox

Start a stopped sandbox by name or ID.

Parameters
{
  "sandbox": "my-project"     // sandbox name or ID
}

stop_sandbox

Gracefully stop a running sandbox.

Parameters
{
  "sandbox": "my-project",
  "force": false              // optional: force kill
}

delete_sandbox

Permanently delete a sandbox and all its data.

Parameters
{
  "sandbox": "my-project"
}

Tunnel Tools

enable_tunnel

Create a Cloudflare tunnel for a sandbox and return the public URL.

Parameters
{
  "sandbox": "my-project"
}
Returns
{
  "tunnel_url": "https://abc123.trycloudflare.com",
  "status": "active"
}

disable_tunnel

Disconnect the tunnel for a sandbox.

Parameters
{
  "sandbox": "my-project"
}

get_tunnel_url

Get the current tunnel URL and status for a sandbox.

Parameters
{
  "sandbox": "my-project"
}

Execution Tools

exec_command

Execute a command inside a running sandbox container and return the output.

Parameters
{
  "sandbox": "my-project",
  "command": "ls -la /workspace",
  "timeout": 30               // optional: timeout in seconds (default: 30)
}
Returns
{
  "exit_code": 0,
  "stdout": "total 24\ndrwxr-xr-x  5 user user 4096 ...",
  "stderr": ""
}

Commands run as the default container user. Be cautious with destructive commands. The timeout parameter prevents long-running commands from blocking the agent.

Monitoring Tools

get_logs

Retrieve container logs for a sandbox.

Parameters
{
  "sandbox": "my-project",
  "tail": 100,                // optional: number of lines (default: 100)
  "since": "5m"               // optional: time window ("5m", "1h", "2d")
}

get_resource_usage

Get real-time CPU, memory, and disk usage for a sandbox or all sandboxes.

Parameters
{
  "sandbox": "my-project"     // optional: omit for aggregate stats
}

Usage Examples

Once the MCP server is connected, you can ask your AI agent to manage sandboxes in natural language:

"Create a new sandbox called api-test using the Claude agent with port 8080 exposed"

"Show me all running sandboxes and their resource usage"

"Enable a tunnel for the api-test sandbox and give me the URL"

"Run 'npm install' inside the api-test sandbox"

"Get the last 50 lines of logs from api-test"

"Stop and delete the api-test sandbox"

Troubleshooting

MCP server not appearing in Claude Desktop

  • Verify that csb is in your PATH by running which csb
  • Check the Claude Desktop MCP log for errors
  • Restart Claude Desktop after modifying the config file

Tools returning errors

  • Ensure the Local API is enabled in Settings (the MCP server depends on it)
  • Verify Docker is running: docker info
  • Check the Coding Sandbox logs for errors (Settings > Advanced > Log file)

exec_command timing out

  • Increase the timeout parameter for long-running commands
  • Ensure the sandbox is in a running state
  • Check container resource usage — the sandbox may be resource-constrained