colab-cloud-mcp
Runs the MCP server inside Google Colab GPU runtimes, providing tools to inspect runtime/GPU status, execute Python in a persistent namespace, manage background jobs, and export executed code and plots as a notebook.
Provides file management tools for browsing, reading, and writing files in the Colab workspace and mounted Google Drive, including saving logs and model weights to Drive.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
colab-cloud-mcp
让 Claude 云端对话(网页 / 手机 App / Desktop Custom Connectors)、Google Antigravity 以及 Claude Code 通过公网 HTTPS (443) Streamable HTTP 协议直接连接 Google Colab GPU 运行时的远程 MCP Server。
为什么需要这个项目?
本地 stdio 模式的 Colab MCP 依赖本机 CLI 进程与本机浏览器标签页桥接——一旦合上笔记本电脑、休眠或本地网络闪断,连接就会立即断开,且无法在网页版或手机端云对话中使用。
colab-cloud-mcp 将 MCP 服务端直接运行在 Google Colab 虚拟机内部,并通过 HTTPS 隧道(Cloudflare Tunnel 或 ngrok)暴露符合最新规范的 Streamable HTTP 端点:
真正脱离本机:云端对话客户端直接访问 Colab 端服务,本机合盖、断网或切换到手机端对话均不断连。
SSE 心跳防断流:
POST /mcp的tools/call请求自动采用 SSE 流式心跳保活,防止超过 100 秒时触发 Cloudflare Tunnel HTTP 524 超时。持久化 Python 命名空间 + 自动捕获图表:
execute_python跨轮次保留所有变量、PyTorch 模型与显存张量;Matplotlib 绘图自动转为 PNG 图像块回传给对话界面。异步后台长任务与重启持久化:内置
start_background_job/get_job_status/cancel_job,支持数小时模型训练或大权重下载至 Google Drive;任务元数据与日志落盘持久化,服务端重启后仍可继续追踪与查询日志。安全重跑与优雅停止:同一端口重复运行启动单元格会自动停止旧服务与隧道,避免端口占用与旧 Token
401冲突;也可随时调用mcp_server.stop()手动关闭服务与隧道。会话导出为
.ipynb:随时调用export_session_notebook将执行过的所有代码与输出图像保存为标准 Jupyter Notebook。三重鉴权兼容所有客户端:
零请求头加密路径模式(
<TUNNEL_URL>/s/<MCP_TOKEN>/mcp):适配 Claude Custom Connectors 的No sign in模式,粘贴单条 URL 即可安全鉴权。标准 Bearer Header 模式(
Authorization: Bearer <MCP_TOKEN>):适配 Google Antigravitymcp_config.json、Claude Code HTTP MCP 与 Claude Request Headers。内置 OAuth 2.1 (PKCE + DCR):完整实现
/.well-known/oauth-protected-resource、/.well-known/oauth-authorization-server、动态客户端注册与 PKCE 授权码流程。
Related MCP server: Smart Colab MCP Bridge
快速开始(在 Google Colab 中运行)
点击顶部 Open in Colab 徽章,或打开本仓库的 notebooks/colab_cloud_mcp.ipynb 按顺序执行即可启动服务并打印所有客户端接入配置。重复运行 Step 3 单元格会自动清理旧实例并无缝重启;如需手动释放端口与隧道,可运行 mcp_server.stop()。
合盖前在最后一个单元格运行保活监控:
mcp_server.keep_alive(status_interval_seconds=60)Colab 实例生命周期提示:MCP 连接本身已完全脱离本机,但 Google Colab 对免费版/Pro 版在关闭全部浏览器标签页后仍有后台空闲回收时间窗口;如需合盖后持续运行数小时,建议配合
keep_alive()或 Colab Pro+ 后台执行,并将日志与权重保存至/content/drive/MyDrive。
固定域名配置(重启 Colab 免改客户端 URL)
在 Colab 左侧 Secrets 中配置以下密钥并以 provider="auto" 启动:
方案 | Colab Secrets 变量名 | 说明 |
固定鉴权密钥 |
| 自定义高强度字符串,重启免改 Token |
Cloudflare Named Tunnel |
| 在 Cloudflare Zero Trust Tunnel 将子域名指向本地端口 |
ngrok 免费静态域名 |
| 使用 ngrok 账号免费静态域名(需安装 |
客户端接入指南
1. Claude 云端(Custom Connectors)
进入 Customize -> Connectors -> + Add -> Add custom connector
最简方式(免配 Header):URL 填入启动器打印的
<TUNNEL_URL>/s/<MCP_TOKEN>/mcp,Authentication 选择No sign inHeader / OAuth 方式:URL 填入
<TUNNEL_URL>/mcp,在 Request headers 添加Authorization: Bearer <MCP_TOKEN>或选择 OAuth 授权
2. Google Antigravity(App / IDE / CLI)
编辑 ~/.gemini/config/mcp_config.json 或工作区 .agents/mcp_config.json:
{
"mcpServers": {
"colab-remote": {
"url": "<TUNNEL_URL>/mcp",
"headers": {
"Authorization": "Bearer <MCP_TOKEN>"
}
}
}
}3. Claude Code CLI
claude mcp add -s user --transport http colab-remote <TUNNEL_URL>/mcp \
--header "Authorization: Bearer <MCP_TOKEN>"内置 MCP 工具一览
工具名称 | 功能说明 |
| 查看 GPU 型号与显存 ( |
| 在持久化命名空间执行 Python 代码,自动捕获 |
| 清空持久化变量并触发 |
| 执行 Bash 命令(支持工作目录与超时进程组清理) |
| 通过 |
| 异步启动长时间后台训练或大权重下载任务,日志与元数据实时落盘持久化 |
| 查询后台任务状态与末尾日志、列出或终止后台任务 |
| 浏览、按行读取或写入 Colab 工作区与 Google Drive 文件 |
| 对已有文本文件进行精确局部查找与替换(支持单次匹配或全量替换) |
| 读取工作区或 Google Drive 中的图片文件并以图像内容块直接回传对话界面 |
| 将当前会话执行过的所有代码与图表导出为 |
本地测试
python3 tests/test_server.pyLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Remote streamable-HTTP MCP server running on a single Cloudflare Worker. Your assistant gets live Airbnb, Amazon, Booking.com, Google Flights, Maps and Reddit data, social search on X, Instagram and TikTok, the Meta Ad Library, and image/video generation without any keys. Connect your own accounts to let it send WhatsApp or Telegram messages, work an IMAP inbox, manage Meta Ads campaigns and publish to X and LinkedIn. OAuth 2.1 with PKCE; stored credentials are AES-256-GCM encrypted.
Connect Splashtop to AI assistants via UniversalMCP stateless Streamable HTTP.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Deploy websites, apps, agents and MCP servers from Claude Code or Codex. OAuth, runs in Taiwan.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to autonomously manage Google Colab GPU sessions, submit and monitor training jobs, and debug/fix issues via an encrypted tunnel without requiring a browser tab.MIT
- FlicenseNot gradedqualityDmaintenanceConnects Claude Desktop to a Google Colab runtime via ngrok for remote Python execution, enabling GPU/CPU code execution with smart timeouts and file management.1-
- AlicenseAqualityCmaintenanceEnables local agents to connect to and interact with Google Colab sessions running in the browser.3Apache 2.0
- AlicenseBqualityCmaintenanceBridges a locally running coding agent to a Colab session in the browser, letting it inspect, edit, run, and export notebooks, execute ad-hoc Python, transfer files to and from the runtime, and poll or cancel background jobs.12Apache 2.0