ScratchRun

dev.scratchrun由 scratchrun.dev 发布v0.1.1更新于 Oct 24, 2026

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

概览

AI 生成的概览

在一次性隔离的 MicroVM 中运行简短的 Python、Node 或 Bash 代码片段,并返回标准输出、标准错误、退出码和输出文件。

可以做什么
ScratchRun 提供一个工具 scratchrun_exec,在全新的硬件隔离 MicroVM 中执行代码,并返回标准输出、标准错误、退出码以及所请求的输出文件。调用方可选择运行时(python3.12、python3.11、node20 或 bash),设置超时和内存上限,传入环境变量,在运行前写入输入文件,并在运行后以 base64 取回文件。图片输出会以 MCP 图片内容块返回。每次调用后虚拟机即被销毁,因此各次运行之间不保留任何状态。
适用场景
适合助手需要真正运行代码的场景,例如快速计算、数据转换、生成图表或测试代码片段,而不必触碰用户自己的机器,也不会留下状态。它面向一次性的无状态执行,不适合长时间任务或需要在多次调用间保留文件的工作。
运行要求
需要本地 Node.js 运行时,通过 npx 运行 npm 包 @scratchrun/mcp-server,并提供 ScratchRun API 密钥,放在环境变量 SCRATCHRUN_API_KEY 中。需要能访问 ScratchRun 服务的网络。仅支持桌面客户端,不支持网页端执行。
安装前请注意
该服务器需要密钥 SCRATCHRUN_API_KEY,该密钥会发送给第三方服务;传给 scratchrun_exec 的代码和文件会离开用户机器在远端执行。传给该工具的环境变量用于存放密钥,因此不要把凭据写进代码字符串。执行由服务商计费或受配额限制;沙箱会屏蔽私有网段和云元数据地址,因此需要访问内网的代码会失败。

安装

在 SourceWeft 中

  1. 打开 控制台中的 ScratchRun,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

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:

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:

ParameterTypeRequiredDescription
runtimepython3.12 | python3.11 | node20 | bashyesRuntime to use
codestringyesCode to execute
timeout_msintegernoTimeout in ms (default 10000, max 30000)
memory_mbintegernoMemory limit in MB (default 256, max 512)
envobjectnoEnvironment variables — use for secrets, not code strings
filesobjectnoFiles to write before execution (path → content)
return_filesstring[]noFile paths to capture after execution (returned as base64)

Example — run Python and return a chart:

json
{  "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)
  • TerminateMicroVM called 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; /tmp is RAM-backed and gone with the VM

Latency

~400ms median (warm pool). 2–8s cold start if the pool is empty.

License

MIT

来源:README.md,提交 2d8ebee

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.1最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。