CodeSandbox MCP Server
Provides tools for CodeSandbox sandbox lifecycle management (create, resume, hibernate, inspect, update), session creation/resume, and sandbox filesystem operations (read, list, write, rename) via the CodeSandbox SDK.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CodeSandbox MCP Server create a private sandbox and list the files in its root directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CodeSandbox MCP Server
A Model Context Protocol (MCP) server that exposes CodeSandbox SDK operations as tools for AI agents.
Runtime: Node.js 18+
Auth:
CODESANDBOX_API_TOKEN(orCSB_API_KEY)SDK: Official
@codesandbox/sdk
Install / Run
Use via npx in your MCP client config.
Example (Cursor/Claude Desktop mcp.json snippet):
{
"mcpServers": {
"codesandbox": {
"command": "npx",
"args": [
"-y",
"@techlibs/codesandbox-mcp@latest",
"--read-only"
],
"env": {
"CODESANDBOX_API_TOKEN": "<your-api-token>"
}
}
}
}CLI binary name: mcp-server-codesandbox
You can also run directly:
npx -y @techlibs/codesandbox-mcp@latest --helpFlags:
--read-only: disallow mutating tools (write/rename) and default sessions to read permission--vm-tier <tier>: default VM tier when creating/resuming--hibernation-timeout <seconds>: default inactivity hibernation timeout--keep-alive: keep sessions active while connected--log-level <error|warn|info|debug>
Related MCP server: microsandbox-mcp
Tools (Stateless)
All tools are stateless: no server-managed session registry. Each call performs the SDK operation directly using only the provided arguments.
createSandboxDescription: Create a sandbox (optionally from template
id) and optionally start with custom VM settings.Params:
privacy(public|private): Privacy of the sandbox.title(string): Optional title.description(string): Optional description.tags(string[]): Up to 10 tags.path(string): Destination folder path inside your workspace.id(string): Template sandbox ID to fork from.ipcountry(string): ISO 3166-1 alpha-2 country hint for VM scheduling.vmTier(string): VM tier (e.g. Pico, Nano, ...). Overrides server default.hibernationTimeoutSeconds(number): Inactivity timeout before VM hibernates.automaticWakeupConfig.http(boolean): Auto-wake on HTTP.automaticWakeupConfig.websocket(boolean): Auto-wake on WebSocket.
resumeSandboxDescription: Resume (or start) a sandbox VM.
Params:
sandboxId(string): Target sandbox ID.
hibernateSandboxDescription: Hibernate a sandbox VM (saves and sleeps the VM).
Params:
sandboxId(string): Target sandbox ID.
getSandboxInfoDescription: Get sandbox metadata without starting the VM.
Params:
sandboxId(string): Sandbox ID to fetch.
updateSandboxDescription: Update VM settings for a running sandbox.
Params:
sandboxId(string): Target sandbox ID.vmTier(string): Change VM tier (Pico|Nano|Micro|Small|Medium|Large|XLarge).hibernationTimeoutSeconds(number): Update inactivity hibernation timeout.
createSessionDescription: Create a session for a sandbox (no state is stored server-side).
Params:
sandboxId(string): Target sandbox ID.sessionId(string, optional): Provide a specific session ID; if omitted a UUID is generated.permission(read|write): Session permission. Usereadfor safe, non-mutating access.env(Record<string,string>, optional): Environment variables for the session.git(object, optional): Git identity/options for the session creation.provider(string): e.g. "github".username(string, optional)accessToken(string, optional)email(string)name(string, optional)
resumeSessionDescription: Connect to an existing session by
sandboxId+sessionId. If the session does not exist, it will be created using the optional parameters.Params:
sandboxId(string): Target sandbox ID.sessionId(string): Session identifier to connect to.permission(read|write, optional): Used if creating the session.env(Record<string,string>, optional): Used if creating the session.
readFileDescription: Read a file from the sandbox filesystem. The tool connects per call using
sandboxId+sessionId.Params:
sandboxId(string): Target sandbox ID.sessionId(string): Session identifier (created if missing as needed).permission(read|write, optional): Used if creating the session.env(Record<string,string>, optional): Used if creating the session.path(string): Absolute path inside the sandbox filesystem.encoding(utf8|base64, optional): Encoding for the returned content (defaultutf8).
readdirDescription: List files and directories at a given path. The tool connects per call using
sandboxId+sessionId.Params:
sandboxId(string): Target sandbox ID.sessionId(string): Session identifier (created if missing as needed).permission(read|write, optional): Used if creating the session (defaults toreadin read-only mode).env(Record<string,string>, optional): Used if creating the session.path(string): Absolute path to list within the sandbox filesystem.
writeFileDescription: Write a file in the sandbox filesystem. The tool connects per call using
sandboxId+sessionId.Params:
sandboxId(string): Target sandbox ID.sessionId(string): Session identifier (created if missing as needed). Must allow write.permission(read|write, optional): Used if creating the session (typicallywrite).env(Record<string,string>, optional): Used if creating the session.path(string): Absolute path to the file.content(string): Content to write (encoded perencoding).encoding(utf8|base64, optional): Content encoding (defaultutf8).overwrite(boolean, optional): Overwrite existing file (defaulttrue).create(boolean, optional): Create the file if missing (defaulttrue).
renameDescription: Rename/move a file or directory. The tool connects per call using
sandboxId+sessionId.Params:
sandboxId(string): Target sandbox ID.sessionId(string): Session identifier (created if missing as needed). Must allow write.permission(read|write, optional): Used if creating the session (typicallywrite).env(Record<string,string>, optional): Used if creating the session.from(string): Source path.to(string): Destination path.overwrite(boolean, optional): Overwrite if destination exists (defaulttrue).
Notes:
Filesystem operations connect a
SandboxClientfor the duration of the call and dispose it immediately; no state is retained.Outputs are returned as text blocks (JSON payloads serialized to string) for broad client compatibility.
Development
Build:
npm run buildDev (stdio):
npm run dev(requires token env var)
Environment
CODESANDBOX_API_TOKEN(preferred) orCSB_API_KEY: PAT with scopes for Sandbox Creation, Read/Edit, VM Manage, Preview Token Manage.
Limitations
This server targets CodeSandbox sandboxes (VMs), not legacy projects.
Session resume uses
sandbox.connect({ id: sessionId }).
Available Tools
11 toolscreateSandboxC
Create a CodeSandbox sandbox (optionally from a template) and optionally start with custom VM settings.
Inputs: id, path, tags, title, +6 more.
createSessionB
Create a CodeSandbox session for a sandbox. Returns the sessionId without storing state on the server.
Inputs: sandboxId (required), env, git, sessionId, +1 more.
getSandboxInfoA
Get metadata for a sandbox by ID without resuming the VM (title, description, privacy, tags).
Inputs: sandboxId (required).
hibernateSandboxB
Hibernate a sandbox (saves files and puts VM to sleep).
Inputs: sandboxId (required).
readdirARead-only
List files and directories at a given path in the sandbox filesystem. Stateless: connects per call using sandboxId+sessionId.
Inputs: path (required), sandboxId (required), sessionId (required), env, +1 more.
readFileBRead-only
Read a file from the sandbox filesystem. Stateless: connects per call using sandboxId+sessionId.
Inputs: path (required), sandboxId (required), sessionId (required), env, +2 more.
renameB
Rename (move) a file or directory within the sandbox filesystem. Stateless: connects per call using sandboxId+sessionId.
Inputs: to (required), from (required), sandboxId (required), sessionId (required), +3 more.
resumeSandboxB
Resume a hibernated sandbox or start it if shut down.
Inputs: sandboxId (required).
resumeSessionA
Connect to an existing session by sandboxId + sessionId. If the session does not exist, it will be created with optional permission/env.
Inputs: sandboxId (required), sessionId (required), env, permission.
updateSandboxB
Update VM settings for a running sandbox: tier and/or hibernation timeout.
Inputs: sandboxId (required), vmTier, hibernationTimeoutSeconds.
writeFileB
Write a file in the sandbox filesystem. Stateless: connects per call using sandboxId+sessionId.
Inputs: path (required), content (required), sandboxId (required), sessionId (required), +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools target clearly distinct lifecycle stages or filesystem actions, but resumeSession also creates a session if absent, overlapping createSession, and resumeSandbox vs resumeSession may require careful reading. Boundaries are mostly clear but not fully unambiguous.
Names overwhelmingly follow camelCase verb+object patterns such as createSandbox, getSandboxInfo, and readFile. The exceptions readdir and rename are minor deviations from that otherwise predictable convention.
The 11 tools fit the sandbox, session, and filesystem scope well; each maps to a concrete operation and none appears redundant. This is within the typical appropriate range for a focused MCP server.
Core sandbox/session setup and file read/write/rename/list operations are present, but there is no tool to delete a sandbox, close or terminate a session, delete files, create directories, or execute commands in the sandbox. These are notable gaps for full lifecycle and filesystem coverage, though basic workflows are still possible.
Maintenance
Related MCP Connectors
Linux VMs for AI agents: create VMs, run commands, edit files and open preview URLs.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Build Apps and run code in 30 languages — sandboxed, with persistent sessions for agent loops.
Cloud Linux VMs for your agent: run code, Docker, files and HTTPS previews in a Sandboxer microVM.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to create, modify, and deploy web projects through the AICre8 platform's sandbox environment. It supports project management, code generation, and direct shell command execution for streamlined web development.79 npmMIT
- AlicenseAqualityCmaintenanceConnects AI agents to microsandbox for creating lightweight sandboxes, executing code, managing files, and monitoring resources.19476 npm20Apache 2.0
- AlicenseAqualityDmaintenanceEnables AI assistants to securely execute Python and JavaScript code in sandboxed environments, with file management and package installation.7MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI clients to manage and execute development commands within isolated Railway sandboxes, providing a remote shell, file read/write, and sandbox lifecycle management for running tests, builds, and repository operations.-