SuperAPIAI Directory

colab-mcp

github.com · AI coding

Control Google Colab notebooks and assign GPUs (T4/L4/A100). Fork of Google's colab-mcp with all tools visible at startup and Windows support.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

colab-mcp (enhanced fork) is an MCP server for controlling Google Colab from any AI coding agent. It is based on googlecolab/colab-mcp, fixes defects in the official repository that hinder daily use, and restores functionality removed by Google upstream.

Purpose This tool is designed to let AI coding agents (such as Claude Code, Codex, Kiro IDE, etc.) directly operate Google Colab notebooks, including opening a browser connection, adding code cells, running code, reading cell status, and programmatically assigning a GPU after OAuth is configured.

Main capabilities

  • All 9 tools are visible at startup: 1 connection tool (open_colab_browser_connection) + 7 notebook tools + 1 GPU control tool (change_runtime). In the official version, most MCP clients can only see open_colab_browser_connection, because the notebook tools depend on notifications/tools/list_changed, and some clients ignore that notification.
  • Complete 7 notebook tools: pre-register get_cells, delete_cell, move_cell (previously missing), and rename execute_cell to run_code_cell to match the browser-side handler. run_code_cell requires passing cellId (from add_code_cell or get_cells); the old cellIndex fallback has been removed.
  • GPU control: through the change_runtime tool, agents can allocate T4 / L4 / A100 without manually clicking in the browser. This feature requires configuring Google OAuth.
  • Stale server detection and cleanup: a built-in process registry (on Windows at %LOCALAPPDATA%\colab-mcp\registry.json, on macOS/Linux at ~/.colab-mcp/registry.json) records the pid, port, host, and started_at of each running instance. Dead entries are automatically cleaned up at startup, and its own entry is removed on clean shutdown. Provides --list-running / --kill-stale flags and clearer timeout diagnostics, fixing upstream issue #84 "Disconnected from the local Colab MCP server".
  • Windows support: fixes the Windows port blocking error (WinError 10013) and changes the OAuth port to 8085.
  • IPv4 single-socket binding: forces host="127.0.0.1", avoiding the problem in the official version where host="localhost" + port=0 causes dual sockets (IPv6 ::1 and IPv4 127.0.0.1) to bind to different ephemeral ports and only one of them to be reported, resulting in a 50% probability of connection failure. This invariant is asserted at startup, and a RuntimeError is thrown if future changes reintroduce dual binding.
  • Browser tab deduplication mitigation: appends the current port as a query parameter (?p=<port>) after the Colab URL, so that each server instance produces a unique URL and avoids Chrome focusing an old tab because it ignores the #fragment.

Usage Quick start (no OAuth, notebook tools only):

  1. Install uv (note: do not use pip install uv, as that version lacks the required functionality).
  2. Clone the repository: git clone https://github.com/SebastianGilPinzon/colab-mcp
  3. Configure the MCP client by adding the colab-proxy-mcp definition in .mcp.json (Claude Code, Cursor, etc.). Note: define it in only ONE .mcp.json file to avoid a dual global and project definition resulting in two server instances with one silently dying.
  4. Restart the editor / reload the window.
  5. All 8 tools should appear immediately (open_colab_browser_connection + 7 notebook tools).
  6. Call open_colab_browser_connection to open the Colab notebook in the browser.
  7. Use add_code_cell, run_code_cell, get_cells, etc. to control the notebook.

Full setup (including OAuth + GPU control):

  1. Create OAuth credentials: requires a Google Cloud project configured with OAuth (one-time setup, about 5 minutes). Steps include: create a GCP project, configure the OAuth consent screen (select "External" > Create, app name Colab MCP, add your email as support and developer contact), add yourself as a test user, create an OAuth client ID (Credentials > Create Credentials > OAuth client ID > Desktop app), download the JSON file and save it (e.g. ~/.config/colab-oauth.json). Note: OAuth client IDs can only be created through the Cloud Console web UI; there is no CLI or API.
  2. Add the --client-oauth-config parameter in the MCP configuration pointing to the OAuth JSON file.
  3. First authorization: on the server's first startup it opens a browser for Google OAuth consent; log in and click Allow. The token is cached in ~/.colab-mcp-auth-token.json and refreshes automatically.

After installation (via uv run or uvx git+https://github.com/SebastianGilPinzon/colab-mcp),colab-mcp commands support the relevant flags.

Use cases

  • Development using AI coding agents (Claude Code, Cursor, Windsurf, Codex, etc.) where the agent needs to directly read and write Colab notebook state.
  • Allocating a GPU (T4/L4/A100) for Colab without browser interaction for model training or inference.
  • Windows users using Colab MCP.
  • Users encountering issues such as tools not being visible in the official version, dropped connections, or stale server ports being occupied.

Limitations

  • GPU control (change_runtime) requires configuring Google OAuth, involving the creation of a Google Cloud project and an OAuth client.
  • Requires an MCP client that supports the standard tool protocol; in the official version some clients ignore notifications/tools/list_changed, which this branch resolves by pre-registering at startup.
  • Chrome's local network access policy may block the Colab tab from connecting to the local server; you need to click Allow in the permission prompt; if you previously clicked Block, you need to reset the site permissions.
  • The browser tab deduplication issue has been mitigated, but if you still encounter it, close all colab.research.google.com tabs and retry.
  • This branch is based on the Apache 2.0 license, the same as upstream. Google does not accept external contributions to the official repository, so these fixes are located in this branch.
  • The demo file docs/demo.gif is marked as TODO and is not yet provided.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools