create_sandboxLABSCO SUMMARY
Code that runs somewhere other than your laptop.
The sandbox is created for the task and closed after it, so an agent can install a package and run code it just wrote without any of it touching your filesystem.
What it is
A Python MCP server that hands out isolated sandbox environments for code execution, backed by E2B behind an abstract interpreter interface so another backend can be swapped in. Ten tools create a sandbox, run code in it, install packages, check its status and close it (or do all of that in one call), and list, read, write and upload files inside it.
What you get
- An isolated sandbox created on demand
- Python executed inside that sandbox
- Packages installed into the sandbox before the code that needs them runs
- The current status of a sandbox you created
- The sandbox closed when the task is finished
Requirements
Python 3.10 or higher, plus fastmcp, python-dotenv and e2b-code-interpreter. An E2B key in the environment covers the default backend, and a second environment variable selects which backend is used, defaulting to e2b. Code runs on E2B's infrastructure, not on your machine.
Setup effort
Build from source — git clone https://github.com/chrishayuk/mcp-code-sandbox.git
USE CASES
Running code an agent just wrote
Create the sandbox, execute the code, close it — the machine that runs the untested part is not yours.
Trying a library you do not want installed locally
Install the package into the sandbox, run the snippet that uses it, and throw the environment away.
Picking a session back up
Check the sandbox is still alive before sending more code to it.
Cleaning up after a long session
Sandboxes stay until closed, so shutting them down is an explicit call.
10 tools
Listed in project docs. Your client may show a different list.
close_sandboxget_sandbox_statusexecute_codeinstall_packagecreate_run_closelist_filesread_filewrite_fileupload_fileBEFORE YOU INSTALL
What to know first
Tools you get
10 tools named in the project's documentation.
Requires
- Python 3.10 or later
- E2B_API_KEY in your environment
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
Server setup
git clone https://github.com/chrishayuk/mcp-code-sandbox.git
cd mcp-code-sandbox
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install fastmcp python-dotenv e2b-code-interpreterCreate a .env file in the clone with E2B_API_KEY=<YOUR_E2B_API_KEY> (INTERPRETER_TYPE=e2b is the default)
MCP Clients
Claude Desktop
{
"mcpServers": {
"code-sandbox": {
"command": "<YOUR_PATH_TO_PROJECT_DIRECTORY>/venv/bin/python",
"args": [
"<YOUR_PATH_TO_PROJECT_DIRECTORY>/main.py"
]
}
}
}<YOUR_PATH_TO_PROJECT_DIRECTORY> is the absolute path to your clone. The command is the Python inside the venv the steps create (on Windows, venv\Scripts\python.exe), because a bare python does not have fastmcp or e2b-code-interpreter.
The configuration on this page does not set E2B_API_KEY; the project's instructions put it in a .env file. Check which folder the server reads that file from before you rely on it.