colab-cli-mcp
Enables execution of Python code on Google Colab GPU/TPU runtimes and provides management of Colab sessions, kernels, files, and logs.
Allows mounting a Google Drive in a Colab session to access and transfer files from the VM.
Click on "Install 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-cli-mcpStart a T4 GPU session and run this Python code"
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-cli-mcp
Google 公式の google-colab-cli をラップした
リモート MCP サーバーです。ブラウザ・ws://localhost・SSH トンネルを一切使わずに、
Notion AI などの MCP クライアントから Colab の GPU/TPU ランタイムで Python を実行できます。
Notion AI ──HTTPS(OAuth)──▶ colab-cli-mcp ──subprocess──▶ colab CLI ──HTTPS──▶ Colab runtimeMCP ツール
ツール | 対応する CLI | 説明 |
|
| ランタイム作成(gpu: T4/L4/G4/H100/A100、tpu: v5e1/v6e1、無指定は CPU) |
|
| セッション一覧(runtime token は返しません) |
|
| 状態確認 |
|
| ランタイム解放 |
|
| カーネル再起動 |
|
| Python コード実行 |
|
| pip インストール |
|
| VM 上のファイル一覧 |
|
| VM 上のテキストを取得 |
|
| VM 上にテキストを書き込み |
|
| 大きい/バイナリファイル用 |
|
| ファイル削除 |
|
| Google Drive マウント |
|
| 実行履歴 |
|
| 同じ VM にブラウザから接続する URL |
|
| CLI バージョン |
repl / console / edit / ssh / pay / update は対話専用なので意図的に除外しています。
Related MCP server: mcp-colab-gpu
2 層の認証
MCP クライアント → 本サーバー:
--auth token|none|google|github|oidc本サーバー → Colab: Colab CLI 自身の
--colab-auth oauth2|adc
1. MCP 側(Notion AI から繋ぐ)
colab-cli-mcp \
--transport http --host 0.0.0.0 --port 8080 --path /mcp \
--auth google \
--base-url https://colab-mcp.example.com \
--oauth-client-id xxxxx.apps.googleusercontent.com \
--oauth-client-secret GOCSPX-xxxxx \
--allowed-identity a24.be8a@g.chuo-u.ac.jpGoogle Cloud Console のリダイレクト URI には <base-url>/auth/callback を登録します。
公開が必要なエンドポイント: /mcp, /.well-known/oauth-authorization-server,
/.well-known/oauth-protected-resource/mcp, /authorize, /token, /register,
/consent, /auth/callback。
警告:
--allowed-identityを省略すると、OAuth を通った 任意の Google アカウントが あなたの Colab で任意コードを実行できます。必ず自分のアドレス(または@domain)を指定してください。
2. Colab CLI 側(ヘッドレスサーバーでの初回認証)
CLI はブラウザなしでも認証できます(auth.py の remote flow / token_usage=remote)。
サーバー上で 1 回だけ手で実行してトークンを作ります。
# コンテナ内で 1 回だけ
docker compose run --rm colab-cli-mcp sh -c "colab sessions"
# → 表示された URL を手元のブラウザで開き、
# 表示された認可コードを貼り付ける(~/.config/colab-cli/token.json に保存)ADC を使う場合は --colab-auth adc にして、
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~/.config/colab-cli/ と workspace は 必ず volume で永続化してください(compose 済み)。
Docker
export COLAB_CLI_MCP_BASE_URL=https://colab-mcp.example.com
export COLAB_CLI_MCP_OAUTH_CLIENT_ID=...
export COLAB_CLI_MCP_OAUTH_CLIENT_SECRET=...
export COLAB_CLI_MCP_ALLOWED_IDENTITY=you@example.com
docker compose up -d --buildTLS は Caddy / nginx / Cloudflare Tunnel などで前段終端してください。
環境変数
COLAB_CLI_MCP_ + TRANSPORT / HOST / PORT / PATH / AUTH / AUTH_TOKEN(csv) /
BASE_URL / OAUTH_CLIENT_ID / OAUTH_CLIENT_SECRET / OAUTH_SCOPE(csv) /
OAUTH_REDIRECT_PATH / OAUTH_NO_CONSENT / OIDC_CONFIG_URL / ALLOWED_IDENTITY(csv) /
EXECUTABLE / COLAB_AUTH / COLAB_OAUTH_CONFIG / COLAB_STATE / WORKSPACE
設計上のポイント
ローカル FS のサンドボックス: upload/download のローカル側は workspace 配下に限定(
..は拒否)。セッション単位のロック: Colab カーネルは同時 1 リクエストなので
asyncio.Lockで直列化。秘密情報の非公開:
sessions.jsonのtoken(runtime proxy token)はツール出力から除去。出力の正規化: rich の枠線・ANSI・アップデートバナーを除去してから返す。
既知の上流バグ: 長時間実行は google-colab-cli#14 (80 秒で無応答)の影響を受ける可能性があります。
run_codeのtimeoutは余裕を持たせてください。
開発
uv sync
uv run ruff check . && uv run ruff format --check .
uv run pytest -qThis server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceLocal-first MCP server for controlling Google Colab as a development, shell, file, and training runtime, with tools for notebook editing, GPU acceleration, and file transfer.Last updated595Apache 2.0
- AlicenseAqualityCmaintenanceEnables MCP-compatible AI assistants to run Python code on Google Colab GPU/TPU runtimes, supporting accelerators like T4, A100, H100, with background execution and Google Drive integration.Last updated102MIT
- AlicenseAqualityDmaintenanceMCP server that allocates Google Colab GPU runtimes (T4/L4) and executes Python code on them. Lets any MCP-compatible AI assistant run GPU-accelerated code without local GPU hardware.Last updated37MIT
- Apache 2.0
Related MCP Connectors
Remote MCP for Gemini upgrade evals, prompt regressions, output diffs, and eval receipts.
Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).
Create, browse, remix, collaborate on, and run durable AI workflow nodes from MCP hosts.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/animationsaver/colab-cli-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server