# ScratchRun [Health: Active]

**Category:** 👨‍💻 Code Execution  
**Repository:** https://github.com/ar-blues/scratchrun-mcp  
**GitHub Stars:** 0  
**npm Downloads (last month):** 1148  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/scratchrun

## Description
Ephemeral MicroVM-isolated code execution for AI agents. Fresh VM per call, hard-purged after.

## Tools
Capabilities this server exposes over MCP:

- **scratchrun_exec** — Execute code in an ephemeral, MicroVM-isolated sandbox. The VM is hard-purged after execution — no state, no files, nothing persists between calls. Full internet egress (RFC 1918 + cloud metadata always blocked). Use return_files to capture output artifacts (charts, CSVs, data files) as base64. Keep secrets out of code strings — pass them via env instead.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "scratchrun": {
    "command": "npx",
    "args": ["-y","@scratchrun/mcp-server"],
    "env": {
      "SCRATCHRUN_API_KEY": ""
    }
  }
}
```

**Requires environment variables:** `SCRATCHRUN_API_KEY` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What ScratchRun MCP server does

ScratchRun MCP server gives an MCP-compatible agent one execution tool, `scratchrun_exec`, for running code in isolated MicroVMs. Supported runtimes are Python 3.12, Python 3.11, Node.js 20, and Bash. Every invocation receives a new virtual machine rather than sharing a prior execution environment.

The tool returns the program's standard output, standard error, and exit code. It can also collect selected files created during the run. Captured files are returned as base64; PNG, JPG, and SVG images are exposed as MCP image content blocks so compatible clients can display them inline.

The execution model suits agents that need temporary computation, data transformation, report generation, or visual output without retaining a workspace between requests.

## How it works

A request specifies a runtime and code string. Optional inputs include an environment-variable map, files to create before execution, a timeout, a memory ceiling, and paths to return afterward. The default timeout is 10,000 milliseconds and the maximum is 30,000 milliseconds. Memory defaults to 256 MB and can be raised to 512 MB.

Each run uses hardware virtualization with its own kernel. After execution, the MicroVM is terminated unconditionally and is not reused. The system filesystem is read-only through OverlayFS, while `/tmp` is RAM-backed and disappears with the VM. Network access to RFC 1918 address space and the cloud metadata address `169.254.x.x` is blocked at the network layer.

Warm-pool requests have a reported median latency of about 400 milliseconds. When no warm capacity is available, startup may take approximately 2–8 seconds.

## Setup and configuration

The ScratchRun MCP server can be launched through `npx` using the package `@scratchrun/mcp-server`. Add a server entry to the MCP client configuration with `npx -y @scratchrun/mcp-server` as the command and provide `SCRATCHRUN_API_KEY` in its environment. An API key is obtained from scratchrun.dev.

A minimal configuration uses the `scratchrun` server name, the `npx` command, the `-y` and package-name arguments, and the API key environment variable. Pass secrets through the tool's `env` object when code needs them; do not embed those values directly in code strings.

## Tools and capabilities

The ScratchRun MCP server exposes `scratchrun_exec` with these inputs:

- `runtime`: required; one of `python3.12`, `python3.11`, `node20`, or `bash`.
- `code`: required source text to execute.
- `timeout_ms`: optional execution limit from the default of 10,000 up to 30,000 milliseconds.
- `memory_mb`: optional limit from the default of 256 up to 512 MB.
- `env`: optional environment variables for the process.
- `files`: optional path-to-content mapping for files created before execution.
- `return_files`: optional paths to capture after execution.

For example, an agent can run a Python plotting script, save an image under `/tmp`, and request that path in `return_files`.

## Limitations and notes

Execution is intentionally non-persistent: files, installed state, and other VM contents are removed after each call. Work that depends on a previous invocation must recreate its inputs in a later request. Runtime choice is limited to the four listed options, and execution time and memory are capped by the documented maximums.

Network restrictions block private RFC 1918 ranges and cloud metadata access. The material does not describe package installation behavior, persistent storage, additional runtimes, or a mechanism for retaining state across calls, so those should not be assumed.

_Full upstream README: https://allmcps.com/mcp/scratchrun/readme_

