Programmatic control of Google Colab for developers and AI agents — allocate GPUs, run code & notebooks, sync files, without the website.
Project description
colabctl
Drive Google Colab from code, the terminal, or an AI agent — allocate GPU/TPU runtimes, run code and notebooks, stream outputs, and sync files, without ever touching the Colab website. And when Colab isn't the right fit, run the same job on Modal, Vertex AI, or Hugging Face through one interface.
import asyncio
from colabctl import ColabClient
async def main():
async with ColabClient() as colab:
async with await colab.allocate(gpu="T4") as gpu:
r = await gpu.run("import torch; print(torch.cuda.get_device_name(0))")
print(r.text) # → Tesla T4
asyncio.run(main())
Status: alpha. The Colab paths (official-CLI transport + a from-scratch
/tun/m/*transport) and the Modal backend are validated against real accounts; Vertex / Hugging Face / the browser-bridge are implemented and unit-tested but not yet live-validated. SeeROADMAP.mdfor the honest, detailed status.
Install
Not on PyPI yet — install from GitHub (PyPI publishing is wired up and goes live on the first tagged release; then
pip install colabctlwill work).
pip install "colabctl[cli,sdk,native,secrets] @ git+https://github.com/mandipadk/colabctl.git"
# or as a CLI tool (exposes `colabctl` and `colabctl-mcp`):
uv tool install "colabctl[cli,sdk] @ git+https://github.com/mandipadk/colabctl.git"
Extras: cli, sdk, native, secrets, mcp, drive, modal, vertex, hf,
browser (or all).
Authenticate (Colab)
The sanctioned Colab path uses Google Application Default Credentials:
gcloud auth application-default login \
--scopes=openid,https://www.googleapis.com/auth/cloud-platform,\
https://www.googleapis.com/auth/userinfo.email,\
https://www.googleapis.com/auth/colaboratory,\
https://www.googleapis.com/auth/drive.file
(Other backends use their own credentials — MODAL_TOKEN_*, HF_TOKEN, GCP for Vertex.)
Use it
Python SDK — allocate a GPU, run code, get typed results, auto-release:
async with ColabClient() as colab:
async with await colab.allocate(gpu="A100") as gpu:
await gpu.upload("train.py", "content/train.py")
result = await gpu.run("exec(open('content/train.py').read())")
await gpu.download("content/model.pt", "model.pt")
@remote — ship a local function to a GPU and get its return value back:
from colabctl import remote
@remote(gpu="A100")
def train():
import torch
return torch.cuda.get_device_name(0)
print(train()) # blocks, runs on an A100, returns the device name
CLI:
colabctl run train.py --gpu T4 # one-shot: allocate → run → release
colabctl new --gpu A100 --name myjob # keep a runtime; attach later
colabctl exec -s myjob -c "print(2**10)"
colabctl job run train.py --backend modal --gpu A100 --req torch # any backend
colabctl job backends # list backends + capabilities
From an AI agent (MCP) — let Claude / Codex drive Colab and run jobs on Modal/Vertex/HF:
{ "mcpServers": { "colabctl": { "command": "colabctl-mcp" } } }
Backends
One job API (submit / status / logs / result / cancel) with capability-based routing
and automatic failover — a Colab outage or quota block degrades to another backend
instead of failing.
| Backend | What it's for | ToS posture | Live-validated |
|---|---|---|---|
| Colab (CLI + native) | Your Colab Pro GPUs, interactive or batch | sanctioned (native is opt-in) | ✅ |
| Modal | gVisor-isolated GPU sandboxes; great for agent code | sanctioned | ✅ |
| Vertex AI | Headless, deadline-bound production jobs | sanctioned | ⏳ impl + tests |
| Hugging Face Jobs | Durable, cheap GPU jobs | sanctioned | ⏳ impl + tests |
How it works
colabctl wraps Google's official google-colab-cli/colab-mcp as the sanctioned
default, keeps a from-scratch /tun/m/* transport as a co-equal opt-in path (so
you're never hostage to an immature dependency), and puts the durable engineering into
a capability-detecting provider abstraction so the product survives Colab churn and
abuse-detection bans by routing elsewhere.
- Architecture:
SPEC.md· design decisions:DECISIONS.md· research:RESEARCH.md - Docs:
docs/(uvx mkdocs serve) - Contributing:
CONTRIBUTING.md· Roadmap & status:ROADMAP.md
A note on Terms of Service
colabctl defaults to Google's sanctioned tooling on paid Colab Pro, where automated
use is permitted with a positive compute-unit balance. The reverse-engineered native
transport is disabled by default (COLABCTL_ENABLE_NATIVE=1 to opt in). Opaque
abuse-detection bans can still affect any account; colabctl treats that as a disclosed,
first-class fact and lets you fail over to other backends. Don't share/resell access,
and respect each backend's terms.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file colabctl-0.1.0.tar.gz.
File metadata
- Download URL: colabctl-0.1.0.tar.gz
- Upload date:
- Size: 556.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74dd968e47ce8bea1f20f8ef8d75cd52713ea5ae34f11658db1eeb970d8094c5
|
|
| MD5 |
9c03dcc1066b6fcbea0cd794ea2d8064
|
|
| BLAKE2b-256 |
f05b221491855da6e0d355647140632eb1d7c656d2bd84a4f3b0fc76853f2803
|
File details
Details for the file colabctl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: colabctl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 83.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3983da810c7ddb4ed38f37021282829b60c8e961e41799bda6a5d08890ec6ba5
|
|
| MD5 |
92a3f0a8dd4352fe88c0ca7bdf0b00ef
|
|
| BLAKE2b-256 |
64e2ee78ef71d1042c507b418b378e089a4e70ed31cf3373b50468eca8d467da
|