
Mcp Server Colab Exec
io.github.pdwi2020由 GitHub 帳號 pdwi2020 發布v0.1.0更新於 Oct 24, 2026
Execute Python code on Google Colab GPU runtimes (T4/L4) from any MCP client
概覽
一個本機 MCP 伺服器,可分配 Google Colab GPU 執行環境並在其上執行 Python 程式碼,讓助理不必具備本機 GPU 硬體也能取得 GPU 算力。
- 可以做什麼
- 在 Colab GPU 執行環境上執行內嵌 Python 程式碼,可選擇 T4 或 L4 加速器與逾時時間,並以 JSON 回傳每個儲存格的輸出、錯誤與 stderr。在目前工作區內執行本機 .py 檔案於 Colab GPU 執行環境。執行程式碼並把產生的圖片、CSV、模型權重等產物下載到本機輸出目錄。
- 適用情境
- 適合助理需要執行 GPU 加速的 Python(CUDA、PyTorch、TensorFlow)或訓練並匯出模型,而本機沒有 GPU 的情況。也適合在 Colab 執行環境上快速檢查 GPU 是否可用或查看 nvidia-smi 輸出。
- 執行需求
- 以 Python 套件形式在本機執行(Python 3.10+),可透過 pip 或 uvx 安裝,並在 MCP 用戶端中設定為 stdio 伺服器。需要可存取 Colab 的 Google 帳號,首次執行需在瀏覽器中完成 Google OAuth2 授權;權杖會快取在本機並自動更新。需要連線至 Colab 的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Server Colab Exec,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-server-colab-exec
MCP server that allocates Google Colab GPU runtimes (T4/L4) and executes Python code on them. Lets any MCP-compatible AI assistant — Claude Code, Claude Desktop, Gemini CLI, Cline, and others — run GPU-accelerated code (CUDA, PyTorch, TensorFlow) without local GPU hardware.
Prerequisites
- Python 3.10+
- A Google account with access to Google Colab
- On first run, a browser window opens for OAuth2 consent. The token is cached at
~/.config/colab-exec/token.jsonfor subsequent runs.
Installation
Or run directly with uvx:
Configuration
Claude Code
Add to your project's .mcp.json or ~/.claude/.mcp.json:
Or via the CLI:
Claude Desktop
Add to claude_desktop_config.json:
Gemini CLI
Tools
colab_execute
Execute inline Python code on a Colab GPU runtime.
Returns JSON with per-cell output, errors, and stderr.
colab_execute_file
Execute a local .py file on a Colab GPU runtime.
Security policy: file_path must be a .py file inside the current workspace (cwd).
colab_execute_notebook
Execute code and collect all generated artifacts (images, CSVs, models, etc.).
Artifacts are downloaded as a zip and extracted into output_dir.
Zip members are validated before extraction to prevent path traversal and special-file writes.
Examples
Check GPU availability:
Run nvidia-smi:
Train a model and download weights:
Authentication
On first use, the server opens a browser window for Google OAuth2 consent. The access token and refresh token are cached at ~/.config/colab-exec/token.json. Subsequent runs use the cached token and refresh it automatically.
The OAuth2 client credentials are the same ones used by the official Google Colab VS Code extension ([email protected]). They are intentionally public.
Troubleshooting
"GPU quota exceeded" — Colab has usage limits. Wait and retry, or use a different Google account.
"Timed out creating kernel session" — The runtime took too long to start. Retry — Colab sometimes has delays during peak usage.
"Authentication failed" — Delete ~/.config/colab-exec/token.json and re-authenticate.
OAuth browser window doesn't open — Ensure you're running in an environment with a browser. For headless servers, authenticate on a machine with a browser first and copy the token file.
License
MIT
來源:README.md,提交 b67d0d7
工具
0版本歷史
1- v0.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分