{
  "markdown": "# mcp-server-colab-exec\n\n<!-- mcp-name: io.github.pdwi2020/mcp-server-colab-exec -->\n\nMCP 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.\n\n## Prerequisites\n\n- Python 3.10+\n- A Google account with access to [Google Colab](https://colab.research.google.com)\n- On first run, a browser window opens for OAuth2 consent. The token is cached at `~/.config/colab-exec/token.json` for subsequent runs.\n\n## Installation\n\n```bash\npip install mcp-server-colab-exec\n```\n\nOr run directly with `uvx`:\n\n```bash\nuvx mcp-server-colab-exec\n```\n\n## Configuration\n\n### Claude Code\n\nAdd to your project's `.mcp.json` or `~/.claude/.mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"colab-exec\": {\n      \"command\": \"mcp-server-colab-exec\"\n    }\n  }\n}\n```\n\nOr via the CLI:\n\n```bash\nclaude mcp add colab-exec mcp-server-colab-exec\n```\n\n### Claude Desktop\n\nAdd to `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"colab-exec\": {\n      \"command\": \"mcp-server-colab-exec\"\n    }\n  }\n}\n```\n\n### Gemini CLI\n\n```bash\ngemini mcp add colab-exec -- mcp-server-colab-exec\n```\n\n## Tools\n\n### `colab_execute`\n\nExecute inline Python code on a Colab GPU runtime.\n\n| Parameter     | Type   | Default | Description                              |\n|---------------|--------|---------|------------------------------------------|\n| `code`        | string | —       | Python code to execute (required)        |\n| `accelerator` | string | `\"T4\"` | GPU type: `\"T4\"` (free) or `\"L4\"` (premium) |\n| `timeout`     | int    | `300`   | Max execution time in seconds            |\n\nReturns JSON with per-cell output, errors, and stderr.\n\n### `colab_execute_file`\n\nExecute a local `.py` file on a Colab GPU runtime.\n\n| Parameter     | Type   | Default | Description                              |\n|---------------|--------|---------|------------------------------------------|\n| `file_path`   | string | —       | Path to a local `.py` file (required)    |\n| `accelerator` | string | `\"T4\"` | GPU type: `\"T4\"` (free) or `\"L4\"` (premium) |\n| `timeout`     | int    | `300`   | Max execution time in seconds            |\n\nSecurity policy: `file_path` must be a `.py` file inside the current workspace (`cwd`).\n\n### `colab_execute_notebook`\n\nExecute code and collect all generated artifacts (images, CSVs, models, etc.).\n\n| Parameter     | Type   | Default | Description                              |\n|---------------|--------|---------|------------------------------------------|\n| `code`        | string | —       | Python code to execute (required)        |\n| `output_dir`  | string | —       | Local directory for downloaded artifacts (required) |\n| `accelerator` | string | `\"T4\"` | GPU type: `\"T4\"` (free) or `\"L4\"` (premium) |\n| `timeout`     | int    | `300`   | Max execution time in seconds            |\n\nArtifacts are downloaded as a zip and extracted into `output_dir`.\nZip members are validated before extraction to prevent path traversal and special-file writes.\n\n## Examples\n\n**Check GPU availability:**\n```\ncolab_execute(code=\"import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0))\")\n```\n\n**Run nvidia-smi:**\n```\ncolab_execute(code=\"import subprocess; print(subprocess.run(['nvidia-smi'], capture_output=True, text=True).stdout)\")\n```\n\n**Train a model and download weights:**\n```\ncolab_execute_notebook(\n    code=\"import torch; model = torch.nn.Linear(10, 1); torch.save(model.state_dict(), '/tmp/model.pt')\",\n    output_dir=\"./outputs\"\n)\n```\n\n## Authentication\n\nOn 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.\n\nThe OAuth2 client credentials are the same ones used by the official Google Colab VS Code extension (`google.colab@0.3.0`). They are intentionally public.\n\n## Troubleshooting\n\n**\"GPU quota exceeded\"** — Colab has usage limits. Wait and retry, or use a different Google account.\n\n**\"Timed out creating kernel session\"** — The runtime took too long to start. Retry — Colab sometimes has delays during peak usage.\n\n**\"Authentication failed\"** — Delete `~/.config/colab-exec/token.json` and re-authenticate.\n\n**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.\n\n## License\n\nMIT\n",
  "bytes": 4622,
  "sha": "f9c33412d79f4ebae94465b57887928055db9d77b79fee3c093bd79804a99540",
  "repo_slug": "pdwi2020/mcp-server-colab-exec",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_pdwi2020_mcp_server_colab_exec_3e8c0717/readme"
}