awx

← Blog

Walk-through · 19 November 2026

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.

Awi the cat agent running

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:

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:

  1. Make a project, for example awx-colab-demo.
  2. Turn on the Colab API. In APIs and services, Library, search for Colab and press Enable. Its service name is colaboratory.googleapis.com.
  3. 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.
  4. 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.
Google Cloud console, Create OAuth client ID: application type Desktop app, name awx agent, and the box Use this client for an AI-powered agent ticked
The new option for clients that agents use.

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:

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:

  1. 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.
  2. Found the right field name. Its first create_runtime call failed. It read the tool’s schema and saw the machine type goes in runtimeSpec, not spec.
  3. 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.
  4. Ran code on the GPU. It opened a session and ran nvidia-smi through execute_code: a Tesla T4, with PyTorch already installed. Passing the session name alone worked; passing the runtime as well did not.
  5. Trained, then copied the numbers home. The training printed its results as JSON, which the agent saved on the awx computer and drew as a chart. matplotlib was not installed there, so it drew the chart with Pillow, which was, rather than install anything.
  6. 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.
The awx chat on a phone: the agent reports the training ran on a Tesla T4 GPU in Colab and the runtime is deleted; test accuracy 98.11% after epoch 1, 98.81% after epoch 2 and 98.85% after epoch 3
The agent’s summary in the awx chat.

The result

EpochTime on the T4Test accuracy
110.0 s98.11%
26.8 s98.81%
36.5 s98.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.

Line chart titled MNIST test accuracy per epoch, Tesla T4 on Colab: 98.11% at epoch 1, 98.81% at epoch 2, 98.85% at epoch 3
The chart the agent drew on the awx computer, from the numbers the T4 sent back.

What it cost

Good to know

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

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.

Open awx

Awi the cat agent celebrates with confetti

Awi, signing off.

← All posts