About ScratchRun
ScratchRun is an MCP server for AI agents that runs code in fresh, hardware-isolated MicroVMs and destroys each VM after execution. It supports Python, Node.js, and Bash, with no files or state retained between calls.
Key features
- 01Fresh MicroVM for each run
- 02Python, Node.js, and Bash runtimes
- 03Configurable time and memory limits
- 04Input and output file handling
- 05Network access blocks private and metadata IPs
Use cases
- 01Run agent-generated code in an isolated environment
- 02Generate charts and retrieve image files
- 03Execute scripts without carrying state across runs
MCP support
Exposes the `scratchrun_exec` tool to MCP clients for code execution. Results include stdout, stderr, exit code, and requested output files; images can be returned as MCP image content.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
npx -y @scratchrun/mcp-serverSCRATCHRUN_API_KEYSecretScratchRun API key — get one at https://scratchrun.devLocal servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.
Tools
1Saved tool list · updated 3w ago
| Parameter | Type | Required | Description |
|---|---|---|---|
| env | object | No | Environment variables injected into the sandbox. Use for secrets and config. |
| code | string | Yes | Code to execute. |
| files | object | No | Files to write before execution. Keys are absolute paths, values are file contents. |
| runtime | enum | Yes | Runtime. python3.12 includes numpy, pandas, matplotlib, requests, and more.python3.12 | python3.11 | node20 | bash |
| memory_mb | integer | No | Memory limit in MB. |
| timeout_ms | integer | No | Execution timeout in milliseconds. Exit code 124 signals timeout. |
| return_files | array | No | File paths to capture after execution and return as base64. Use for charts, CSVs, or any output artifact. |
Details
From the project README@scratchrun/mcp-server
MCP server for ScratchRun — ephemeral, MicroVM-isolated code execution for AI agents.
Each call runs in a fresh hardware-isolated MicroVM. The VM is hard-purged after execution. No state, no files, nothing persists between calls.
Install
Add to your claude_desktop_config.json:
{
"mcpServers": {
"scratchrun": {
"command": "npx",
"args": ["-y", "@scratchrun/mcp-server"],
"env": {
"SCRATCHRUN_API_KEY": "sr_live_your_key_here"
}
}
}
}
Get an API key at scratchrun.dev.
Tool: scratchrun_exec
Executes code in an ephemeral sandbox and returns stdout, stderr, exit code, and any output files.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
runtime | python3.12 | python3.11 | node20 | bash | yes | Runtime to use |
code | string | yes | Code to execute |
timeout_ms | integer | no | Timeout in ms (default 10000, max 30000) |
memory_mb | integer | no | Memory limit in MB (default 256, max 512) |
env | object | no | Environment variables — use for secrets, not code strings |
files | object | no | Files to write before execution (path → content) |
return_files | string[] | no | File paths to capture after execution (returned as base64) |
Example — run Python and return a chart:
{
"runtime": "python3.12",
"code": "import matplotlib.pyplot as plt\nimport numpy as np\nx = np.linspace(0, 10, 100)\nplt.plot(x, np.sin(x))\nplt.savefig('/tmp/plot.png')",
"return_files": ["/tmp/plot.png"]
}
Output files are returned as base64. Image files (PNG, JPG, SVG) are returned as MCP image content blocks and render inline in Claude.
Isolation
- Hardware-virtualized MicroVM per execution (own kernel, not a shared-kernel container)
TerminateMicroVMcalled unconditionally after every run — VM destroyed, never reused- RFC 1918 + cloud metadata (
169.254.x.x) always blocked at the network layer - Read-only system filesystem via OverlayFS;
/tmpis RAM-backed and gone with the VM
Latency
~400ms median (warm pool). 2–8s cold start if the pool is empty.
License
MIT
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.