colab-mcp
Allows opening Colab notebooks from GitHub .ipynb blob links, raw.githubusercontent.com links, and Gist links for agent interaction.
Allows connecting a local agent to Google Colab sessions in the browser, enabling notebook cell inspection, editing, execution, file transfer, and notebook export.
Allows opening Colab notebooks from Google Drive share links or bare Drive file IDs so the agent can work with the specified notebook.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@colab-mcp Run this Python in my Colab and show the plot"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Colab-mcp
An MCP server for bridging your local agent to a Colab session in the browser.
Supported Clients
This MCP server requires client support for notifications/tools/list_changed and for the client to be running locally on your device.
Popular clients that fit these criteria include:
Gemini CLI
Claude Code
Windsurf
Setup
Install
uv(pip install uv)Configure for usage (eg for mcp.json style services):
...
"mcpServers": {
"colab-mcp": {
"command": "uvx",
"args": ["git+https://github.com/googlecolab/colab-mcp"],
"timeout": 30000
}
}
...(If you have a non-standard default package index (Googlers), you may also need to add --index https://pypi.org/simple)
Opening a specific notebook (local fork)
This fork extends open_colab_browser_connection with an optional notebook_url
argument so an agent can connect to the notebook you hand it instead of the
scratch notebook:
Colab links (
colab.research.google.com/...,colab.google.com/...)Google Drive share links or bare Drive file ids
GitHub
.ipynbblob orraw.githubusercontent.comlinksGist links
Calling it with a different notebook_url while connected disconnects the current
tab and opens the new notebook. A colab_connection_status tool reports whether a
tab is connected and which notebook it was opened for, without touching the browser.
COLAB_MCP_UI_TIMEOUT (seconds, default 60) controls how long the opener waits for
you to accept the connection in the tab.
Run from this checkout with uv run --project /path/to/colab-mcp colab-mcp.
Connection lifecycle (local fork)
Persistent identity. The websocket token and port are saved to
~/.colab-mcp/connection.json(owner-readable only; override the directory with--state-dirorCOLAB_MCP_STATE_DIR) so a connected tab survives a server restart.--ephemeralrestores the upstream behaviour of a fresh token and port each start, and--portpins the websocket port.Token rotation. The token rides in the URL fragment of every Colab link the server opens, so it ends up in browser history. A persisted token is replaced once it is older than
COLAB_MCP_TOKEN_MAX_AGE_DAYS(default 30;0never), or immediately with--rotate-token. The port and last notebook are kept; an open tab must be re-opened.Automatic re-open. If the tab drops and the agent calls a notebook tool, the server re-opens the notebook it last opened and waits for the connection instead of failing. Only notebooks opened by the running server are re-opened: the one saved by a previous process is reported as
previous_notebook_urland named in the "not connected" error, but never opened unprompted. SetCOLAB_MCP_AUTO_REOPEN=0to disable.Cancellation-safe waits. Upstream's wait for the browser used
gatherinsidewait_for; a timeout or a cancelled tool call killed the long-lived MCP client, after which every tab was dropped the instant it connected. The wait no longer cancels the client, and a dead session is recycled before a tab is opened.colab_connection_statusalso reports the proxy port, the state and log directories, whether the session is dead, and the server pid.
Related MCP server: colab-mcp
Composite notebook tools (local fork)
Colab's in-browser server exposes seven primitives (get_cells, add_code_cell,
add_text_cell, update_cell, move_cell, delete_cell, blocking run_code_cell).
This fork adds server-side tools built on them:
Tool | What it does |
| Cells as index, id, type, first line, output and error flags. Cheaper than |
| Run code cells by id list or index range, in order, with per-cell stdout/stderr/result/error. |
| Run every code cell from the top; background by default. |
| Run ad-hoc Python through a temporary cell at the end (deleted afterwards unless |
| Poll or stop background runs. Colab cannot interrupt a running cell through this bridge, so cancel stops after the current cell. |
| Copy a local file to the runtime in base64 chunks, verified by SHA-256. |
| Copy a runtime file to this machine, verified by SHA-256. |
| Save the connected notebook as |
Executions are serialised per runtime: a foreground run_code or file transfer waits for
a background job's current cell to finish and then runs before the job's next cell, so two
cells never execute at once and temporary cells never collide.
Large outputs: the websocket bridge now accepts messages up to 64 MiB (the library default of 1 MiB dropped the connection on a ~400 KB output). A proxied or composite call fails fast with a clear error if the tab drops while the call is in flight.
Issues & Discussions
We are using GitHub discussions as the place for issue discussion and feature requests. As discussions mature into action items, we will add those items as issues. This helps us ensure that issues in the issue tracker are well-understood, deduplicated, and actionable. For these reasons, please do NOT open issues directly.
Contributing
We unfortunately don't have the bandwidth to support review of external contributions, and we don't want user PRs to languish, so we aren't accepting any external contributions right now.
If you have a great idea or pain point, we would love to hear about it on our discussions page - the preferred place for issue discussion and feature requests.
Internal - For Colab Developers
Prerequisites
uvis required (pip install uv)Configure git hooks to run repo presubmits
git config core.hooksPath .githooksGemini CLI setup
...
"mcpServers": {
"colab-mcp": {
"command": "uv",
"args": ["run", "colab-mcp"],
"cwd": "/path/to/github/colab-mcp",
"timeout": 30000
}
}
...Available Tools
12 toolscancel_jobB
Stop a background run after its current cell. The running cell itself cannot be interrupted.
Inputs: job_id (required). Returns: object
colab_connection_statusA
Reports whether a Colab browser session is connected and which notebook it was opened for. Does not open a browser.
Inputs: no named parameters. Returns: object
download_fileA
Copy a file from the notebook runtime to this machine, verifying its SHA-256.
Inputs: local_path (required), remote_path (required), overwrite. Returns: object
export_notebookC
Save the connected notebook as an .ipynb file on this machine.
Inputs: local_path (required), include_outputs. Returns: object
get_notebook_outlineB
List cells as index, id, type, first source line and whether outputs exist.
Inputs: no named parameters. Returns: object
job_statusC
Progress and per-cell results of a background run.
Inputs: job_id (required), max_output_chars. Returns: object
list_jobsB
All known background runs, newest last.
Inputs: no named parameters. Returns: object
open_colab_browser_connectionA
Opens a connection to a Google Colab browser session and unlocks notebook editing tools. Pass notebook_url to open a specific notebook instead of the scratch notebook: Colab links, Google Drive share links or file ids, GitHub .ipynb blob/raw links, and gist links are accepted. Calling it with a different notebook_url while connected switches to that notebook. The call waits for the user to accept the connection in the browser tab; on success, list tools again to see the notebook tools.
Inputs: notebook_url. Returns: object
run_cellsA
Run code cells in order: by id list, or by index range (end exclusive), or all.
Each cell blocks until it finishes. For anything that may take more than a minute set background=True and poll job_status; Colab cannot be interrupted through this bridge, so cancel only stops scheduling the next cell.
Inputs: cell_ids, end_index, background, start_index, +2 more. Returns: object
run_codeA
Run ad-hoc Python in the notebook's runtime via a temporary cell at the end.
The cell is deleted afterwards unless keep_cell=True. Images in the output (plots) are returned as image content. background=True returns a job id.
Inputs: code (required), keep_cell, background, max_output_chars.
run_notebookB
Run every code cell from the top. Background by default: poll job_status.
Inputs: background, stop_on_error, max_output_chars. Returns: object
upload_fileB
Copy a local file into the notebook runtime's filesystem (e.g. /content/data.csv).
Transfers in base64 chunks through temporary cells and verifies the SHA-256 on the runtime afterwards.
Inputs: local_path (required), remote_path (required), overwrite. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools target clearly distinct actions (connect, check status, outline, job list, cancel, upload, download, export). The only real overlap is the execution trio run_cells, run_notebook, and run_code — run_cells explicitly accepts 'all', which duplicates run_notebook — but the descriptions spell out the difference well enough for an agent to choose correctly.
Nearly all names are snake_case and follow verb_noun (get_notebook_outline, run_cells, list_jobs, cancel_job, upload_file, download_file, export_notebook). Minor deviations: the status queries job_status and colab_connection_status are noun-only, and open_colab_browser_connection redundantly embeds 'colab' while its sibling tools do not.
Twelve tools is a well-scoped set for remote Colab notebook control: connection handling, execution, job management, file transfer, and export each get a small number of dedicated tools. Nothing appears padded or redundant beyond the mild execution overlap.
Core run lifecycle (connect, inspect cells, execute, poll, cancel, transfer files, export) is covered with no dead ends. However, the notebook-editing tools that open_colab_browser_connection promises to 'unlock' are absent from the surface, and there is no way to insert, delete, or edit cell source or to disconnect a session — notable gaps for a notebook-control server.
Maintenance
Related MCP Connectors
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.
Related MCP Servers
AlicenseAqualityDmaintenanceBridges a local agent to a Colab session in the browser, enabling seamless interaction with Colab from local clients.11,526Apache 2.0- AlicenseAqualityDmaintenanceBridges a local AI agent to a Colab session in the browser, enabling code execution and file operations through the Model Context Protocol.29Apache 2.0
- AlicenseBqualityCmaintenanceLets any MCP-compatible agent use Google Colab or Jupyter runtimes as an execution backend, enabling code execution, notebook management, package installation, hardware introspection, training jobs, and file handling.401MIT
- AlicenseAqualityCmaintenanceEnables local agents to connect to and interact with Google Colab sessions running in the browser.3Apache 2.0