Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/opensandbox-group/OpenSandbox/llms.txt

Use this file to discover all available pages before exploring further.

The OpenSandbox MCP server wraps the OpenSandbox Python SDK as a set of MCP tools, making every sandbox operation — creating and killing sandboxes, running commands, reading and writing files — directly available to MCP-capable AI clients such as Claude Code and Cursor. Once connected, agents can provision isolated sandbox environments, write and execute code, inspect outputs, expose ports, and clean up, all without leaving the chat or editor interface.

Installation

Install the opensandbox-mcp package from PyPI:
pip install opensandbox-mcp
Start the server (defaults to stdio transport):
opensandbox-mcp

Configuration

Environment Variables

Set these before starting the server or inject them through your client’s MCP configuration:
VariableDescription
OPEN_SANDBOX_API_KEYAPI key for authenticating with the OpenSandbox server.
OPEN_SANDBOX_DOMAINServer domain (e.g. localhost:8080 or api.opensandbox.io).

CLI Flags

All configuration can also be passed as flags, which take precedence over environment variables:
opensandbox-mcp --api-key <key> --domain <domain> --protocol http
FlagDescription
--api-keyOpenSandbox API key.
--domainOpenSandbox API domain.
--protocolhttp or https (default: http).
--request-timeout-secondsHTTP request timeout in seconds (default: 30).
--transportTransport mode: stdio (default) or streamable-http.

Client Integrations

Register the MCP server using the claude mcp add command. The server process is started by Claude Code on demand.
claude mcp add opensandbox-sandbox --transport stdio -- \
  opensandbox-mcp --api-key "$OPEN_SANDBOX_API_KEY" --domain "$OPEN_SANDBOX_DOMAIN"

Available MCP Tools

All tools that operate on an existing sandbox require a sandbox_id. Obtain one from sandbox_create or sandbox_connect. The file_read and file_write tools are text-only; use the encoding and range_header parameters for large files.

Sandbox Lifecycle

ToolDescription
sandbox_createCreate a new sandbox and register it locally. Returns the sandbox_id.
sandbox_connectAttach to an existing sandbox by ID and register it locally.
sandbox_killTerminate a sandbox by ID.
sandbox_get_infoFetch full sandbox info (image, state, metadata) by ID.
sandbox_listList sandboxes with an optional filter object.
sandbox_renewExtend the sandbox expiration time.
sandbox_healthcheckCheck whether the sandbox is healthy and ready.
sandbox_get_metricsRetrieve current resource usage metrics.
sandbox_get_endpointGet the public network endpoint URL for a given port.

Command Execution

ToolDescription
command_runRun a shell command inside the sandbox and return output.
command_interruptInterrupt a running command.

Filesystem

ToolDescription
file_readRead a text file from the sandbox.
file_writeWrite a text file to the sandbox.
file_deleteDelete one or more files.
file_searchSearch for files by glob pattern.
file_create_directoriesCreate one or more directories.
file_delete_directoriesDelete one or more directories.
file_moveMove or rename a file or directory.
file_replace_contentsReplace the contents of an existing file.

Typical Workflow

1

Create a sandbox

Call sandbox_create with the desired image (e.g. python:3.12). Save the returned sandbox_id — every subsequent tool call needs it.
2

Write code or assets

Use file_write to place source files, configuration, or data into the sandbox filesystem before execution.
3

Run a command

Call command_run to execute scripts, install dependencies, run tests, or start a service. Output is returned in the tool response.
4

Expose a port (if needed)

If the command started a server, call sandbox_get_endpoint with the port number to get the public URL.
5

Clean up

Call sandbox_kill to terminate the sandbox and release its resources.

Streamable HTTP Transport

By default, opensandbox-mcp uses stdio and is launched as a subprocess by the MCP client. For scenarios where you want a shared, long-running server process — or where your client does not support subprocess management — start the server in streamable-http mode instead:
opensandbox-mcp --transport streamable-http
The server starts on port 8000 and exposes the MCP endpoint at http://localhost:8000/mcp. Any MCP client that supports HTTP transport can then connect to it.
HTTP transport is useful when multiple agents or editor windows need to share the same MCP server process, or when running the server on a remote host.

Build docs developers (and LLMs) love