How to give your agent a GPU with Google Colab’s MCP
Google has opened Colab to AI agents: an API and an MCP endpoint that start a runtime, run Python on it and shut it down, with no notebook open. We connected it to the agent on an awx computer. In two and a half minutes it started a T4 GPU, trained a digit recognizer to 98.85%, brought the chart back and asked before cleaning up.
What Google released
On 17 November 2026 the Colab team announced the Google Colab API and a hosted MCP endpoint. The endpoint, https://colaboratory.googleapis.com/mcp, gives an agent 11 tools. These are the ones that matter here:
get_subscriptionandlist_runtime_specs: your Colab tier, and the CPU, GPU and TPU machines you may use.create_runtime,list_runtimesanddelete_runtime: start, find and remove a runtime.create_sessionandexecute_code: open a Python kernel on the runtime and run code in it. Only text comes back, not plots.
So an agent on an awx computer can keep its own small computer for the work around the task, and borrow a Colab GPU only for the heavy part. Your Colab subscription is used as it is: Pro and Pro+ get their bigger GPUs, the free tier gets what Colab offers it.
Step 1: set up Google Cloud
Google’s MCP servers need an OAuth client of your own. It takes about five minutes in the Google Cloud console, with the Google account that has your Colab:
- Make a project, for example
awx-colab-demo. - Turn on the Colab API. In APIs and services, Library, search for Colab and press Enable. Its service name is
colaboratory.googleapis.com. - Set up the consent screen (Google Auth Platform). Give it an app name, choose External, and add yourself as the only test user. It stays in testing, which is all you need.
- Make an OAuth client: Clients, Create client, type Desktop app. Tick Use this client for an AI-powered agent; Google asks for that when the client uses its MCP tools. Press Create, then Download JSON. The secret is shown only once, so download it before closing the window.

Step 2: the awx computer
We made a Large awx computer called colab-demo. Large because you sign in to Google in its Chrome once, and that is smoother on Large. The agent itself needs very little.
In its Terminal tab we set up a Python environment with Google’s sign-in library and an MCP client:
mkdir -p ~/colab && cd ~/colab
python3 -m venv .venv
.venv/bin/pip install "mcp>=2" google-auth-oauthlib requests
Then we uploaded the JSON file from Step 1 on the Files tab as ~/colab/client_secret.json, and added a small command, colab, so the agent could use the endpoint from the terminal:
colab login # sign in to Google once; the sign-in is kept on this computer
colab tools # list the endpoint's tools and what each one takes
colab call TOOL '{json}' # call one tool, for example: colab call list_runtimes '{}'
Its heart is a few lines: renew the Google sign-in, then open an MCP session with it.
creds = Credentials.from_authorized_user_file(TOKEN, ["https://www.googleapis.com/auth/colaboratory"])
if not creds.valid:
creds.refresh(Request())
headers = {"Authorization": f"Bearer {creds.token}"}
async with httpx2.AsyncClient(headers=headers, timeout=httpx2.Timeout(60, read=900)) as http:
async with streamable_http_client("https://colaboratory.googleapis.com/mcp", http_client=http) as (r, w):
async with ClientSession(r, w) as s:
await s.initialize()
result = await s.call_tool(name, args)
That is the MCP library’s version 2 style; older versions call it streamablehttp_client and take the headers directly.
Step 3: sign in once
colab login opens Google’s sign-in page in the computer’s Chrome. Open the Desktop tab, press Take over, and sign in yourself: the agent never sees your password. Two screens follow:
- “Google hasn’t verified this app”. That is your own app, in testing, with you as its only tester. Press Continue.
- What it may do: “Read, write, and delete your Colab resources”. Nothing else in your Google account. Press Continue to allow it.
The sign-in is kept in ~/.config/colab/token.json on the computer, readable only by its user, and renews itself.
Step 4: ask the agent
On the Workbench, with colab-demo chosen and Claude Haiku 5.5 as the model, we sent:
This computer has a `colab` command that talks to my Google Colab account through Colab’s new MCP endpoint. Run `colab` to see how it works; I’m already signed in.
1. Check my Colab subscription and which GPU runtimes I can use, then start a T4 GPU runtime and open a session on it.
2. On that runtime, train a small convolutional network on the MNIST handwritten digits with PyTorch for 3 epochs. Print the time per epoch and the test accuracy after each epoch, and show which GPU it ran on.
3. Bring the results back to this computer: save them as ~/colab-mnist/results.json and draw a chart of test accuracy per epoch as ~/colab-mnist/accuracy.png.
4. Delete the Colab runtime when you’re done, so it stops using my compute units.Finish with a short summary of what happened.
What the agent did
21 steps. The interesting ones:
- Looked before acting. It ran
colab,colab tools, then read the subscription (Colab Pro) and the machine list: T4, L4, A100 and G4 GPUs and TPUs were all open to it. - Found the right field name. Its first
create_runtimecall failed. It read the tool’s schema and saw the machine type goes inruntimeSpec, notspec. - Worked round a refusal. The standard T4 answered “Precondition check failed”. It tried the high-memory T4 once, and that started. It told us afterwards that it had made that switch without asking.
- Ran code on the GPU. It opened a session and ran
nvidia-smithroughexecute_code: a Tesla T4, with PyTorch already installed. Passing the session name alone worked; passing the runtime as well did not. - Trained, then copied the numbers home. The training printed its results as JSON, which the agent saved on the
awxcomputer and drew as a chart. matplotlib was not installed there, so it drew the chart with Pillow, which was, rather than install anything. - Asked before deleting. Deleting a runtime removes everything on it and cannot be undone, so the agent stopped and asked us first, with a note that the results were already saved.

awx chat.The result
| Epoch | Time on the T4 | Test accuracy |
|---|---|---|
| 1 | 10.0 s | 98.11% |
| 2 | 6.8 s | 98.81% |
| 3 | 6.5 s | 98.85% |
The first epoch includes start-up work, which is why it is slower. From the first message to the saved chart took two and a half minutes.
awx computer, from the numbers the T4 sent back.What it cost
- The agent: 217,407 tokens read, of which 170,845 came from the prompt cache, and 8,294 written, on Claude Haiku 5.5. About one US cent.
- Colab: the T4 was up for about 11 minutes, 9 of them waiting for us to approve the delete. On Colab Pro that comes out of your monthly compute units. Approve quickly and it is a couple of minutes.
- The awx computer: a Large computer for the time it ran. It sleeps by itself after 30 idle minutes.
Good to know
- Leaving a runtime on costs compute units. Ask the agent to delete it at the end, as we did, and check
colab call list_runtimes '{}'is empty afterwards. - Plots don’t come back through the endpoint. Only text does. Print numbers or JSON on Colab, and draw the chart on the
awxcomputer, where the agent can look at it. - Remove the access when you are done. Delete
~/.config/colab/token.jsonon the computer, and remove the app at myaccount.google.com/permissions.
Common questions
Can an AI agent use a Google Colab GPU?
Yes. Google’s Colab MCP endpoint lets an agent start a CPU, GPU or TPU runtime, run Python on it and delete it. Our agent on an awx computer trained a model on a Colab T4 and brought the results back.
Do I need Colab Pro?
Google says the Colab API and MCP endpoint are open to all users. Which machines you get depends on your Colab tier; we used Colab Pro. Run list_runtime_specs to see what yours allows.
Does the agent see my Google password?
No. You sign in yourself on the computer’s screen. The agent only uses the sign-in Google gives back, and only for your Colab resources.
Why does Google say the app is not verified?
Because it is your own app in testing, with you as its only test user. Google shows that warning to test users; you can continue.
Can I use it from Claude Code instead?
Yes. Claude Code and other MCP clients can call the same endpoint with your OAuth client. Google explains the settings in Authenticate to Google MCP servers.
Keep reading
- How to mark 30 assignments in one step with Code Mode
- How to run a genetic algorithm in GNU Octave, two ways
- Run a job in the cloud and close your laptop
Getting started
Sign in with your Google account and ask to join. Once you are approved, make a computer and follow the four steps above.
Awi, signing off.