CodeSandbox logo

CodeSandbox

Organization
techlibs

MCP server for CodeSandbox SDK

Publishertechlibs
Repositorycodesandbox-mcp
LanguageTypeScript
Forks
2
Stars
10
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    CodeSandbox exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    10 stars and 2 forks from the linked repository.

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 (or CSB_API_KEY)
  • SDK: Official @codesandbox/sdk

Install / Run

Use via npx in your MCP client config.

Example (Cursor/Claude Desktop mcp.json snippet):

json
{
  "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:

sh
npx -y @techlibs/codesandbox-mcp@latest --help

Flags:

  • --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>

Tools (Stateless)

All tools are stateless: no server-managed session registry. Each call performs the SDK operation directly using only the provided arguments.

  • createSandbox

    • Description: 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.
  • resumeSandbox

    • Description: Resume (or start) a sandbox VM.
    • Params:
      • sandboxId (string): Target sandbox ID.
  • hibernateSandbox

    • Description: Hibernate a sandbox VM (saves and sleeps the VM).
    • Params:
      • sandboxId (string): Target sandbox ID.
  • getSandboxInfo

    • Description: Get sandbox metadata without starting the VM.
    • Params:
      • sandboxId (string): Sandbox ID to fetch.
  • updateSandbox

    • Description: 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.
  • createSession

    • Description: 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. Use read for 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)
  • resumeSession

    • Description: 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.
  • readFile

    • Description: 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 (default utf8).
  • readdir

    • Description: 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 to read in read-only mode).
      • env (Record<string,string>, optional): Used if creating the session.
      • path (string): Absolute path to list within the sandbox filesystem.
  • writeFile

    • Description: 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 (typically write).
      • env (Record<string,string>, optional): Used if creating the session.
      • path (string): Absolute path to the file.
      • content (string): Content to write (encoded per encoding).
      • encoding (utf8|base64, optional): Content encoding (default utf8).
      • overwrite (boolean, optional): Overwrite existing file (default true).
      • create (boolean, optional): Create the file if missing (default true).
  • rename

    • Description: 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 (typically write).
      • 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 (default true).

Notes:

  • Filesystem operations connect a SandboxClient for 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 build
  • Dev (stdio): npm run dev (requires token env var)

Environment

  • CODESANDBOX_API_TOKEN (preferred) or CSB_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 }).

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "codesandbox": {
      "command": "npx",
      "args": [
        "-y",
        "@techlibs/codesandbox-mcp@latest",
        "--read-only"
      ],
      "env": {
        "CODESANDBOX_API_TOKEN": "<your-api-token>"
      }
    }
  }
}

Use CodeSandbox MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once CodeSandbox is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add CodeSandbox as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the CodeSandbox MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "codesandbox": {
      "command": "npx",
      "args": [
        "-y",
        "@techlibs/codesandbox-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the CodeSandbox MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the CodeSandbox MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use CodeSandbox to help me with this task?
CodeSandbox
Sure. I read it.
Here is what I found using CodeSandbox.

Frequently asked questions

What is the CodeSandbox MCP server used for?

CodeSandbox is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use CodeSandbox MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use CodeSandbox with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use CodeSandbox MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With CodeSandbox connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect CodeSandbox MCP to TypingMind?

CodeSandbox runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does CodeSandbox MCP provide in TypingMind?

CodeSandbox exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use CodeSandbox MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If CodeSandbox requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇