A blazing-fast, native Golang Model Context Protocol (MCP) Server for controlling and scraping Google Colab locally.
GoLab is a highly optimized, cross-platform server implementing the Model Context Protocol (MCP) for Google Colab. Written completely from scratch in Go, it serves as an independent, native alternative to the Python implementation. Wait no longer—bridge the gap between your local AI IDEs and remote Colab virtual machines instantly.
A major advantage of GoLab over the official Python implementation is its static tool architecture. GoLab does not require complex client support for notifications/tools/list_changed. This ensures guaranteed out-of-the-box compatibility with all standard MCP clients without dropping tools or enforcing strict dynamic listening requirements.
✨ Why GoLab?
- Blazing Fast: Written in compiled Go, offering near-zero overhead and immediate WebSocket communication.
- Universal Compatibility: Works fluently with Cursor, Claude Desktop, Gemini Code Assist, Windsurf, and Antigravity.
- Cross-Platform: Zero Python environment headaches. Seamless execution on Windows, macOS, and Linux.
- Persistent Stability: Employs static configurations ensuring safe browser reconnection without ephemeral token desyncs.
🚀 Quick Start
Getting started is identical whether you are running macOS, Linux, or Windows. By utilizing Go's module network, GoLab downloads and builds itself silently in the background.
Prerequisite: Ensure Go (Golang) is installed on your machine.
In your MCP client settings (e.g., Cursor, Claude Desktop, or Gemini Code Assist), you have three options to run the GoLab MCP server:
Option 1: Live Cloud Module (Recommended)
If you have Go installed on your machine, you don't even need to download anything! You can command the AI to pull and execute the server directly from Github in one step:
{
"mcpServers": {
"golab": {
"command": "go",
"args": ["run", "github.com/hoangnecon/golab/cmd/server@latest"],
"env": {
"COLAB_TOKEN": "replace-with-your-secure-token",
"COLAB_WS_PORT": "9090"
}
}
}
}
Option 2: Pre-compiled Binary
Head over to the Releases Tab and download the binary for your system (Windows, Mac, Linux).
{
"mcpServers": {
"golab": {
"command": "/absolute/path/to/downloaded/golab.exe",
"env": {
"COLAB_TOKEN": "replace-with-your-secure-token",
"COLAB_WS_PORT": "9090"
}
}
}
}
⚙️ Configuration Parameters
| Environment Variable | Description | Default |
|----------------------|-------------|---------|
| COLAB_TOKEN | (Required) A secret passcode of your choosing used to secure the WebSocket connection between your browser and your local agent. | "" |
| COLAB_WS_PORT | (Optional) The local port used by the browser to communicate with GoLab. | 9090 |
| COLAB_BASE_URL | (Optional) The Colab domain used when launching new notebook tabs from the IDE. | colab.research.google.com |
📓 Notebook Preparation & Drive Mounting
GoLab drives incredible automation natively, but it must adhere to Google Colab's strict security sandbox boundaries:
- Providing Notebook URLs: When your AI Agent uses the
open_notebooktool, it needs the direct Google Drive Colab File URL (e.g.,https://colab.research.google.com/drive/1YUds...). GoLab will intercept this and automatically append the necessary MCP WebSocket mapping parameters. - Mounting Google Drive: If your workflow requires the AI agent to read/write files directly to Google Drive via the
list_driveorread_filetools, the user must manually mount Drive inside the Colab UI first. You can do this in two ways:- Method A (Native UI): Click the "Folder" icon in the left sidebar of the Colab interface, then click the "Mount Drive" icon.
- Method B (Python Cell): Execute the standard Drive mounting code:
from google.colab import drive drive.mount('/content/drive')
🧰 Available Tools Matrix
GoLab exposes 27 tools to grant your AI comprehensive control over remote execution pipelines.
Connection & Setup
| Tool | Description |
|------|-------------|
| check_status | Pings the WebSocket to verify if the frontend proxy is actively attached. |
| open_notebook | Opens a specified Colab or Drive URL, automatically injecting MCP parameters. |
| get_environment | Returns system info: Python version, CUDA version, GPU model, RAM, disk usage. |
Notebook Reading
| Tool | Description |
|------|-------------|
| get_notebook_outline | Returns the full skeletal structure of the notebook (cell types, previews, definitions). |
| get_cells | Fetches the raw contents of specific cells by index range. |
| get_cell_with_lines | Returns a cell's content with line numbers for precise reference. |
| get_cell_output | Retrieves executed stdout, tracebacks, and Base64 image data. |
| get_running_cells | Lists cells currently being executed on the runtime. |
| get_error_cells | Sweeps the notebook isolating kernel compilation or runtime failures. |
| get_recent_changes | Detects added, modified, and deleted cells since the last call. |
| search_cells | Searches for a text pattern across all cells with line-level context. |
Cell Management
| Tool | Description |
|------|-------------|
| add_code_cell | Inserts a new Python code cell at a specified position. |
| add_text_cell | Inserts a new Markdown cell at a specified position. |
| update_cell | Complete overwrite of an existing cell's content. |
| delete_cell | Removes a target cell from the notebook. |
| move_cell | Moves a cell to a new index position in the notebook. |
| run_code_cell | Executes the target cell directly on Colab's hardware (e.g., L4 GPU/TPU). |
Precision Editing
| Tool | Description |
|------|-------------|
| edit_cell_lines | Slice-and-replace specific lines within a cell without full overwrite. |
| insert_in_cell | Inject code at a specific line number, shifting existing code down. |
| find_replace_in_cell | String substitution within a single cell. |
| find_replace_all | String substitution across all cells in the notebook. |
File I/O & Environment
| Tool | Description |
|------|-------------|
| read_file | Read text files from the Colab VM or mounted Google Drive. |
| write_file | Write content to files on the Colab VM or mounted Drive. |
| list_drive | List files and directories in Google Drive as a JSON tree. |
| create_project_structure | Scaffold a project directory on Drive with data/, models/, checkpoints/, logs/, configs/. |
| list_packages | List all installed Python packages with versions. |
| check_package | Check if a specific Python package is installed and its version. |
📚 Concrete API Examples
Instead of prompting in natural language, here is exactly how your AI Agent and GoLab communicate payload schemas back-and-forth under the hood using the MCP Protocol:
1. Executing a Cell & Reading Output natively
Agent Payload (run_code_cell):
{
"cellId": "jH5vSMErxJwI"
}
GoLab Response:
{
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": ["Epoch 1/50 - loss: 0.4213\n"]
}
]
}
2. Slicing Model Architecture Parameters Directly
Agent Payload (insert_in_cell):
{
"cellId": "g24HDD5s9MNh",
"lineNumber": 4,
"content": "import torch\nimport torch.nn as nn"
}
GoLab Response:
{
"inserted": true,
"linesInserted": 2,
"totalLines": 15
}
🤝 Contributing & Issues
We welcome community contributions to make GoLab even better!
- Check the Issues tab for existing reports or feature requests.
- Fork the repository and create your feature branch.
- Ensure your Go code is formatted (
go fmt) and passes standard checks (go vet). - Submit a Pull Request with a clear description of your architectural changes.
📜 License
This project is an independent native Golang implementation. It is open-sourced under the Apache License 2.0.