/ 目錄 / 演練場 / CodeRunner
● 社群 instavm ⚡ 即開即用

CodeRunner

作者 instavm · instavm/coderunner

為 agent 提供 VM 隔離的程式碼執行環境——Python、Playwright、持久 Jupyter 核心,全部沙箱化,不影響你的主機。

CodeRunner 為 Claude(和其他 agent)提供安全、持久的沙箱:以長效存活的 Jupyter 核心執行 Python、以 Playwright 進行網路擷取、操作 PDF 和圖像。基於容器的 VM 級隔離,讓 agent 可以執行不受信任的程式碼,而不會破壞你的機器。以 MCP 形式暴露,可在任何用戶端中使用。

為什麼要用

核心特性

即時演示

實際使用效果

就緒

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "coderunner-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/instavm/coderunner",
        "~/.claude/skills/coderunner"
      ],
      "_inferred": true
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "coderunner-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/instavm/coderunner",
        "~/.claude/skills/coderunner"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "coderunner-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/instavm/coderunner",
        "~/.claude/skills/coderunner"
      ],
      "_inferred": true
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "coderunner-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/instavm/coderunner",
        "~/.claude/skills/coderunner"
      ],
      "_inferred": true
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "coderunner-skill",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/instavm/coderunner",
        "~/.claude/skills/coderunner"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "coderunner-skill": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/instavm/coderunner",
          "~/.claude/skills/coderunner"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add coderunner-skill -- git clone https://github.com/instavm/coderunner ~/.claude/skills/coderunner

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: CodeRunner

讓 Claude 執行不受信任的程式碼,而不危及你的筆電

👤 試驗自動生成程式碼的開發者 ⏱ ~15 min intermediate

何時使用: 你想讓 Claude 撰寫並執行一個你沒有完全審查的腳本。

前置條件
  • macOS Apple Silicon + Python 3.10+ — 目前的限制;Linux 支援視情況而定
  • Skill 已安裝 — 依專案 README 進行 git clone + ./install.sh
步驟
  1. 交付任務
    Use coderunner. Write a Python script that downloads my Strava activities CSV from <url>, parses, and computes weekly mileage. Run it in the sandbox.✓ 已複製
    → 腳本已執行;結果已顯示;沒有碰觸我的檔案系統
  2. 迭代
    Add a chart of weekly mileage. Re-run.✓ 已複製
    → 圖表已渲染;核心狀態保持(無需重新匯入)
  3. 匯出結果
    Save CSV + chart to ./out/ on host (this only).✓ 已複製
    → 只有那一個路徑被寫入;沙箱保持密封

結果: 快速試驗,不必擔心「糟糕,它刪了 /Users」。

注意事項
  • 沙箱內仍允許網路存取 — 若執行真正不受信任的程式碼,請停用網路;否則它可能洩露資料
搭配使用: filesystem

與 Claude 進行持久資料分析

👤 將 Claude 作為 Jupyter 副駕駛的分析師 ⏱ ~30 min beginner

何時使用: 你想進行 30 分鐘的探索性資料分析,且不希望失去核心狀態。

步驟
  1. 載入一次資料
    Use coderunner. Load /data/sales.csv into df. Show schema + 5 sample rows.✓ 已複製
    → df 在核心中;在對話期間持續存在
  2. 臨時查詢
    Pivot by region × month, show top 5 anomalies.✓ 已複製
    → 樞紐表 + 標記的異常列
  3. 匯出
    Save the anomalies subset to /out/anomalies.csv on host.✓ 已複製
    → CSV 已存至 /out/

結果: 透過對話進行筆記本品質的分析,且程式碼確實有在執行。

注意事項
  • 長時間對話後核心狀態漂移;結果基於過時的變數 — 在不相關的任務之間重啟核心;Claude 可以發出 %reset
搭配使用: filesystem

安全地抓取 JavaScript 密集型網站

👤 需要從 SPA 進行一次性資料擷取的開發者 ⏱ ~20 min intermediate

何時使用: 網站需要完整瀏覽器;你不想在主機上執行 Chrome 程序。

步驟
  1. 啟動工作階段
    Use coderunner Playwright. Open <url>, wait for the table, extract rows as JSON.✓ 已複製
    → JSON 已返回;瀏覽器在沙箱內執行
  2. 迭代選擇器
    Selector missed the price column; adjust to find it.✓ 已複製
    → 更新後的選擇器;資料完整

結果: 資料已擷取;主機上沒有瀏覽器的蹤跡。

注意事項
  • 網站偵測到無頭瀏覽器並封鎖 — 切換至 skill 提供的 chromium 搭配隱身選項

組合

與其他 MCP 搭配,撬動十倍槓桿

coderunner-skill + filesystem

只透過掛載路徑在沙箱中傳入或取出資料

Mount only /Users/me/data and /Users/me/out; everything else is read-only.✓ 已複製
coderunner-skill + duckduckgo-mcp

搜尋 → 擷取 → 分析管線

Search via duckduckgo, scrape via coderunner Playwright, analyze in Python.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
run_python code: str 任何程式碼執行 0
browser_navigate url, wait_for? SPA 抓取的 Playwright 工作階段 0
browser_extract selector, format 導覽後拉取資料 0
pdf_ops input_path, op, args PDF 合併、分割、擷取 0
image_ops input_path, op, args 縮放、格式轉換、OCR 0
kernel_reset 不相關任務之間 0

成本與限制

運行它的成本

API 配額
無——本機
每次呼叫 Token 數
僅有程式碼和輸出的 token
費用
免費
提示
持久核心省去重新匯入的 token;只在狀態錯誤時重置

安全

權限、密鑰、影響範圍

最小權限: 僅限掛載的檔案系統路徑 網路可透過設定開啟或關閉
憑證儲存: 不要將機密放入沙箱,除非你接受 agent 能看到它們
資料出站: 若網路開啟,沙箱可存取任何 URL——敏感執行時請停用
切勿授予: 掛載 $HOME 或 /——沙箱因此失去意義

故障排查

常見錯誤與修復

install.sh 在 Linux 上失敗

此專案以 macOS Apple Silicon 為主要支援平台;Linux 支援視情況而定。查看 issues 中特定發行版的說明

Playwright 狀態過時

執行 kernel_reset;舊的瀏覽器脈絡可能在多次呼叫間持續存在

沙箱無法連接網際網路

設定中已停用網路;若需要請切換開啟。反之,不需要時請隔離

PDF/圖像 skill 缺少依賴項

容器映像內建了常見依賴項;重建映像以新增自訂依賴項

替代方案

CodeRunner 對比其他方案

替代方案何時用它替代權衡
Anthropic 程式碼執行測試版你想要不需要本機沙箱的伺服器端執行雲端端;資料會離開你的機器
手動使用 Docker你想完全控制容器映像需手動設定;沒有開箱即用的 MCP 伺服器

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills