|
| 1 | +# 302_sandbox MCP Server |
| 2 | + |
| 3 | +302 Sandbox MCP |
| 4 | + |
| 5 | +[What is an MCP Server?](https://www.anthropic.com/news/model-context-protocol) |
| 6 | + |
| 7 | +## Characteristics |
| 8 | +Attribute|Details| |
| 9 | +|-|-| |
| 10 | +**Image Source**|Official Image |
| 11 | +|**Author**|[302ai](https://github.com/302ai) |
| 12 | +**Repository**|https://github.com/302ai/302_sandbox_mcp |
| 13 | +**Dockerfile**|https://github.com/302ai/302_sandbox_mcp/blob/main/Dockerfile |
| 14 | +**Docker Image built by**|Docker Inc. |
| 15 | +**Docker Scout Health Score**|  |
| 16 | +**Licence**|MIT License |
| 17 | + |
| 18 | +## Available Tools |
| 19 | +Tools provided by this Server|Short Description |
| 20 | +-|- |
| 21 | +`createSandbox`|Create a Linux sandbox that can execute code, run commands, upload and download files, and has complete Linux functionality.| |
| 22 | +`directRunCode`|Automatically creates a sandbox, executes code, and immediately destroys the sandbox after execution.| |
| 23 | +`downloadSandboxFiles`|Export files from a sandbox directory or file path to downloadable urls.| |
| 24 | +`killSandbox`|Destroy a sandbox by its ID.| |
| 25 | +`listSandboxFiles`|List files and directories at specified paths within a sandbox.| |
| 26 | +`listSandboxes`|Query the list of sandboxes associated with the current API key.| |
| 27 | +`runCode`|Run code on a specific sandbox.| |
| 28 | +`runCommand`|Run a command line command on a specific linux sandbox.| |
| 29 | +`writeSandboxFiles`|Import files from public URLs or base64 data into a sandbox.| |
| 30 | + |
| 31 | +--- |
| 32 | +## Tools Details |
| 33 | + |
| 34 | +#### Tool: **`createSandbox`** |
| 35 | +Create a Linux sandbox that can execute code, run commands, upload and download files, and has complete Linux functionality. After successful creation, a sandbox_id will be returned, and all subsequent operations will need to include this sandbox_id to specify the corresponding sandbox. After successful creation, the sandbox will automatically pause. When calling other sandbox operation interfaces later, it will automatically reconnect and pause again after execution to avoid generating extra costs. |
| 36 | +Parameters|Type|Description |
| 37 | +-|-|- |
| 38 | +`max_alive_time`|`integer`|Maximum alive time of the sandbox (seconds), recommand 300. |
| 39 | +`envs`|`object` *optional*|Environment variables to set (optional) |
| 40 | +`metadata`|`object` *optional*|Sandbox metadata (optional) |
| 41 | +`sandbox_name`|`string` *optional*|Custom sandbox name (optional) |
| 42 | + |
| 43 | +--- |
| 44 | +#### Tool: **`directRunCode`** |
| 45 | +Automatically creates a sandbox, executes code, and immediately destroys the sandbox after execution. Optionally exports sandbox files (compresses multiple files into a zip archive if there are multiple files in the specified path, or exports a single file directly). Recommended for use cases that don't require continuous sandbox operations. |
| 46 | +Parameters|Type|Description |
| 47 | +-|-|- |
| 48 | +`code`|`string`|The source code to be executed in the sandbox |
| 49 | +`language`|`string`|The programming language to execute the code. If not provided or if the value is not in the allowed options, it will be treated as Python code |
| 50 | +`envs`|`object` *optional*|Environment variables to be set during code execution. Supports passing custom environment variables as key-value pairs |
| 51 | +`is_download`|`boolean` *optional*|Flag to indicate whether to download generated files. Must be enabled if the code generates files that need to be retrieved |
| 52 | +`timeout`|`number` *optional*|Maximum execution time in seconds for the sandbox. If code execution exceeds this time, it will be terminated and return a timeout error. Default is 5 |
| 53 | + |
| 54 | +--- |
| 55 | +#### Tool: **`downloadSandboxFiles`** |
| 56 | +Export files from a sandbox directory or file path to downloadable urls. Supports batch export of multiple directories or files. When exporting directories, only common file formats are included (documents, images, audio, video, compressed files, web files, and programming language files). |
| 57 | +Parameters|Type|Description |
| 58 | +-|-|- |
| 59 | +`path`|`string`|Path(s) to export from the sandbox. |
| 60 | +`sandbox_id`|`string`|The ID of the sandbox to export files from |
| 61 | + |
| 62 | +--- |
| 63 | +#### Tool: **`killSandbox`** |
| 64 | +Destroy a sandbox by its ID. |
| 65 | +Parameters|Type|Description |
| 66 | +-|-|- |
| 67 | +`sandbox_id`|`string`|The ID of the sandbox to destroy |
| 68 | + |
| 69 | +--- |
| 70 | +#### Tool: **`listSandboxFiles`** |
| 71 | +List files and directories at specified paths within a sandbox. Supports batch queries with multiple paths. This operation can be used before downloadSandboxFiles to check if the file exists. |
| 72 | +Parameters|Type|Description |
| 73 | +-|-|- |
| 74 | +`path`|`string`| |
| 75 | +`sandbox_id`|`string`|The ID of the sandbox to query files from |
| 76 | + |
| 77 | +--- |
| 78 | +#### Tool: **`listSandboxes`** |
| 79 | +Query the list of sandboxes associated with the current API key. If no parameters are passed, all current sandboxes will be returned. |
| 80 | +Parameters|Type|Description |
| 81 | +-|-|- |
| 82 | +`sandbox_id`|`string` *optional*|Filter by sandbox ID (optional) |
| 83 | +`sandbox_name`|`string` *optional*|Filter by sandbox name provided during creation (optional) |
| 84 | + |
| 85 | +--- |
| 86 | +#### Tool: **`runCode`** |
| 87 | +Run code on a specific sandbox. This returns text output only. For operations that generate files, you'll need to use separate file viewing and export endpoints. Default file saving path is /home/user. |
| 88 | +Parameters|Type|Description |
| 89 | +-|-|- |
| 90 | +`code`|`string`|The code to run |
| 91 | +`sandbox_id`|`string`|The ID of the sandbox to run the code on |
| 92 | +`envs`|`object` *optional*|Environment variables to set when running the code |
| 93 | +`language`|`string` *optional*|The programming language to use. If not specified or if the value is not in the allowed range, it will be treated as Python code. |
| 94 | +`timeout`|`integer` *optional*|The timeout for code execution in seconds |
| 95 | + |
| 96 | +--- |
| 97 | +#### Tool: **`runCommand`** |
| 98 | +Run a command line command on a specific linux sandbox. This returns text output only. For operations that generate files, you'll need to use separate file viewing and download endpoints. |
| 99 | +Parameters|Type|Description |
| 100 | +-|-|- |
| 101 | +`cmd`|`string`|The command line command to run |
| 102 | +`sandbox_id`|`string`|The ID of the sandbox to run the command on |
| 103 | +`envs`|`object` *optional*|Environment variables to set when running the command |
| 104 | +`timeout`|`integer` *optional*|The timeout for command execution in seconds. When installing dependencies or performing similar operations, it is recommended to set it to above 120 seconds. |
| 105 | + |
| 106 | +--- |
| 107 | +#### Tool: **`writeSandboxFiles`** |
| 108 | +Import files from public URLs or base64 data into a sandbox. Supports batch import of multiple files. If the target file already exists, it will be overwritten. If the target directory doesn't exist, it will be automatically created. You must create a sandbox before calling this tool. |
| 109 | +Parameters|Type|Description |
| 110 | +-|-|- |
| 111 | +`file_list`|`array`|List of files to import into the sandbox |
| 112 | +`sandbox_id`|`string`|The ID of the sandbox to write files to. |
| 113 | + |
| 114 | +--- |
| 115 | +## Use this MCP Server |
| 116 | + |
| 117 | +```json |
| 118 | +{ |
| 119 | + "mcpServers": { |
| 120 | + "302_sandbox": { |
| 121 | + "command": "docker", |
| 122 | + "args": [ |
| 123 | + "run", |
| 124 | + "-i", |
| 125 | + "--rm", |
| 126 | + "-e", |
| 127 | + "302AI_API_KEY", |
| 128 | + "mcp/302_sandbox" |
| 129 | + ], |
| 130 | + "env": { |
| 131 | + "302AI_API_KEY": "YOUR_API_KEY_HERE" |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +[Why is it safer to run MCP Servers with Docker?](https://www.docker.com/blog/the-model-context-protocol-simplifying-building-ai-apps-with-anthropic-claude-desktop-and-docker/) |
0 commit comments