Google gives coding agents three official routes into Colab: the colab command-line tool, a local MCP server and a remote MCP endpoint. I installed the CLI, signed it in, started a T4 runtime and pointed opencode, Codex and Claude Code at it. Then I served a model from that T4 and pointed all three agents at it through an SSH tunnel.
The short answer is to use the CLI. Every agent already has a shell, and colab exec is all it needs. The two MCP routes each need something extra, and below is what each one needs and where I hit snags. The same tunnel trick is how Alexey Fateev’s launcher runs a 96 GB model on a Colab G4.
Which route to use
| Route | What the agent gets | What you need | Output |
|---|---|---|---|
| Colab CLI | A shell tool: new, exec, ssh, upload, download, stop | Linux or macOS and a Google sign-in | Anything the code prints, plus files via download |
| Local colab-mcp | Tools for working in a notebook you have open | A Colab tab in a browser on the same machine, and a client that handles tool-list updates | Notebook edits in the browser |
| Remote MCP endpoint | 10 tools, from create_runtime to execute_code | A token with the colaboratory scope and a Google Cloud quota project | Text only, no plots |

Route 1: the Colab CLI
The CLI is Google’s own, published as google-colab-cli, and it runs on Linux and macOS only. I used version 0.8.0.
uv tool install google-colab-cli
colab new -s t4 --gpu T4
echo 'print("hello from Colab")' | colab exec -s t4
colab usage
colab stop -s t4
The first command that needs Google prints a consent URL. You open it, approve, and paste the code back into the terminal. After that colab new brought up a T4.

colab skill prints a bundled skill called colab-operator, which tells an agent how to drive the CLI. That’s the hook for agents. I asked each one to read it first and then use the runtime that already existed, and I allowed Claude Code only the CLI with --allowedTools "Bash(colab:*)". This is the exact prompt:
Read the Colab CLI skill with `colab skill`, then use the `colab` CLI on the existing session named t4 (do not create or stop sessions). Run Python on that session that prints the GPU name and total memory, and whether PyTorch can see CUDA. Report the output.
All three agents read the skill, ran Python on the T4 and reported Tesla T4, 15,360 MiB of memory (14.56 GiB in PyTorch) and CUDA visible. opencode used Claude Haiku 5.5 from the OpenCode catalogue.



Snags
- Codex. Its
workspace-writesandbox keeps~/.configread-only and blocks the network, so the CLI can’t save its token cache or reach Google. Add the config folder as a writable root and turn network access on (config below). - opencode.
opencode runwaits on stdin in a script. Add</dev/nulland it returns. - Sign-in default. The README and
--helpdefault--authtooauth2, while the bundled skill showsadc. If a command asks for credentials you haven’t set up, pass--auth oauth2. - Orphan runtimes. A
colab newthat times out can leave a runtime running. Runcolab usageafterwards; with nothing running the rate reads 0.00/hr. - One SSH session.
colab sshallows one concurrent connection per runtime, so keep it for the tunnel below and usecolab execfor everything else.
The Codex config that fixed the sandbox, in config.toml:
[sandbox_workspace_write]
writable_roots = ["/home/you/.config/colab-cli"]
network_access = true
Route 2: the local MCP server
colab-mcp is a bridge between a local agent and a Colab notebook open in your browser. It runs over stdio, so the client has to be on the same device as the browser, and it has to handle tools/list_changed notifications. The README names Gemini CLI, Claude Code and Windsurf. This is the config:
{
"mcpServers": {
"colab-mcp": {
"command": "uvx",
"args": ["git+https://github.com/googlecolab/colab-mcp"],
"timeout": 30000
}
}
}
I started it and listed its tools. Before a browser tab connects it exposes one, open_colab_browser_connection, and the notebook tools appear after the tab connects. I didn’t connect a tab, so I haven’t run the notebook-editing tools. This route suits working inside a notebook with an agent beside you. It doesn’t suit a headless agent on a server.
Route 3: the remote MCP endpoint
Google also runs an MCP server at https://colaboratory.googleapis.com/mcp. Its tools cover runtimes and sessions: create_runtime, list_runtime_specs, create_session, execute_code, get_runtime and the matching list, get and delete calls. Listing the tools needs no sign-in, which is the curl call on Google’s reference page. Calling them does. You need a token with the colaboratory scope and a Google Cloud quota project, and without the project the call came back with a 403 that says so.
Two limits from Google’s reference matter for agents. execute_code is cut off after 600 seconds with DEADLINE_EXCEEDED while the code keeps running, and you reattach by repeating the call with the same executionId. Output is text only, so plots and images don’t come back. Claude Code can attach a bearer token to an MCP server through a headersHelper script. I stopped at the 403, so I haven’t run execute_code on this route.
Run the model on Colab instead
The routes above put the compute on Colab and the agent on your machine. You can also put the model on Colab. vLLM serves one model over three API shapes, and each agent speaks a different one:
- opencode uses OpenAI chat completions, at
/v1/chat/completions. - Codex uses the Responses API, at
/v1/responses. - Claude Code uses the Anthropic Messages API, at
/v1/messages.

On the T4 I installed vLLM and served Qwen3-4B-Instruct-2507. The 15 GB card can’t hold much cache, so I capped the context at 24,576 tokens:
vllm serve Qwen/Qwen3-4B-Instruct-2507 --port 8000 --served-model-name coder --dtype half --max-model-len 24576 --gpu-memory-utilization 0.88 --enable-auto-tool-choice --tool-call-parser hermes
Then I forwarded the port to my machine through the CLI’s SSH proxy mode:
ssh -N -o ProxyCommand="colab ssh --proxy-mode -s t4" -L 127.0.0.1:18000:127.0.0.1:8000 root@colab-t4

A single curl to each endpoint came back with “Hello there!” in the shape that agent expects.

Pointing each agent at the tunnel takes a few lines. opencode, in opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"colab": {
"npm": "@ai-sdk/openai-compatible",
"name": "Colab T4",
"options": {
"baseURL": "http://127.0.0.1:18000/v1",
"apiKey": "sk-local"
},
"models": {
"coder": {
"name": "Qwen3 4B on Colab",
"limit": {
"context": 24576,
"output": 2048
}
}
}
}
},
"model": "colab/coder"
}
Codex, in config.toml, with COLAB_LOCAL_KEY set to any string:
model = "coder"
model_provider = "colab"
[model_providers.colab]
name = "Colab T4"
base_url = "http://127.0.0.1:18000/v1"
wire_api = "responses"
env_key = "COLAB_LOCAL_KEY"
Claude Code reads the Anthropic base URL from the environment, so it points at http://127.0.0.1:18000 without the /v1 suffix.
For the test I gave each agent one small job:
Create fizzbuzz.py that prints FizzBuzz for 1 to 15, run it with python3, and show me the output.
opencode, Codex and Claude Code each wrote the file, ran it and printed the right sequence with the model on the T4. Getting there took three adjustments:
- Tool calls. A 3B coder model printed its tool calls as plain text, so no agent could act on them. Qwen3-4B-Instruct-2507 with the
hermesparser returned real tool calls. - Claude Code’s prompt. Its default system prompt and tool list overflowed the 24,576-token window, and vLLM refused the request.
--bare, a trimmed tool set and a lowerCLAUDE_CODE_MAX_OUTPUT_TOKENSgot it under the limit. - Codex edits. The served model doesn’t support Codex’s
apply_patchtool, so Codex wrote the file with a shell command instead.

A 4B model on a T4 is good enough to prove the wiring and not much more. The point is that the wiring is identical for a bigger card, which is what the G4 launcher does with a far larger model.
What it costs and what Colab allows
A T4 ran at about 1.2 compute units an hour in my sessions, and colab usage shows the live rate and your balance. A G4 runs at about 10, the rate users have logged, and the earlier piece on the G4 launcher works through what each Google plan’s units buy.
Colab’s FAQ draws three lines that matter here:
- SSH, remote control and web UIs as a secondary feature need a positive paid balance. At a zero balance Colab applies free-tier rules, which don’t allow them.
- Offering a web service from a runtime and using it as a remote proxy are banned on every runtime.
- The terms bar giving third parties access to your runtime.
The tunnel above binds to 127.0.0.1, so it’s built for one person using their own model. Sharing it with a team breaks those rules. The CLI route over colab exec is the one that fits the plainest reading of them.
What I didn’t run
- Fateev’s G4 launcher and the 96 GB model. It needs a G4 and a plan that can start one.
- The notebook-editing tools in colab-mcp, which need a connected browser tab.
execute_codeon the remote endpoint, which needs a quota project.
Sources
- googlecolab/google-colab-cli, README and the bundled
colab-operatorskill - googlecolab/colab-mcp, README
- Colab MCP reference, Google for Developers
- Colab FAQ
- alesha-pro/tools, the
colab-g4-glm53launcher - vLLM documentation
Disclosure: I’m an OpenAI, Firecrawl and Devin ambassador.




