kgsh
Provisions and controls headless Kaggle kernel workers through the Kaggle API: pushes a private bootstrap kernel to boot a Dual-T4 GPU session (with automatic tunnel and authenticated RPC daemon), reports kernel status including GPU/VRAM %, RAM, working-disk space and drain countdown, exchanges connection state via a private Kaggle dataset handshake, mounts previous runs' output as a dataset to chain work beyond the 12h limit, and shuts the kernel down on request.
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.
kaggle-shell-mcp (kgsh) ⚡
Turn free 12h Kaggle Dual-T4 GPUs into live, stateful remote terminals & detached job runners for AI Agents via MCP.
Tiếng Việt (Vietnamese Guide) · Architecture Spec (VN) · Contributing
Why kaggle-shell-mcp?
Kaggle offers ~30 hours/week of free Dual NVIDIA Tesla T4 GPUs (2 × 15 GB = 30 GB VRAM), yet its official API (kaggle kernels push) only supports fire-and-forget batch runs. Existing community scripts either:
Push static notebooks and wait blindly for completion, or
Require manually pasting
ngroktokens into a browser cell, installingopenssh-server, and fixing brokenCUDA/LD_LIBRARY_PATHvariables by hand.
kaggle-shell-mcp (CLI command: kgsh) bridges the gap in one zero-setup MCP server:
Zero Extra Accounts Required: Needs only
KAGGLE_USERNAMEandKAGGLE_KEY(KGAT_...bearer token or legacy key). No ngrok account, no VPN client required (optional Tailscale userspace mode is also supported).100% Native CUDA Environment: Injects a pure-stdlib Python PTY & RPC daemon directly inside the Kaggle Kernel runtime—preserving Conda, PyTorch,
PATH, andLD_LIBRARY_PATHout of the box.Agent-First Execution Split:
term_exec— Stateful/bin/bashPTY (preservescd,export, virtualenvs) for fast interactive exploration and debugging.job_spawn/job_logs— Process-group isolated background jobs that survive network drops, with automatictqdmcarriage-return (\r) compaction so progress bars never blow up LLM context windows.
Built-In Quota & Snapshot Watchdogs:
11h40m Safe Drain: Sends
SIGTERMat11h35mso training loops flush checkpoints, then exits cleanly (exit 0) at11h40m—ensuring Kaggle commits your/kaggle/working(20 GB) output snapshot instead of killing the container at the 12h cliff.Optional Idle Guard: Off by default (
idle_timeout_min=0) so your worker stays ready up to11h40m; passidle_timeout_min=30(orkgsh up --idle 30) to enable automatic shutdown when idle with< 3%GPU utilization.
Related MCP server: Kaggle-MCP-Agent
Architecture
flowchart LR
subgraph Local["Local Machine (Weak / No GPU)"]
Agent["AI Agent\n(Claude / Cursor / Antigravity)"]
MCP["kgsh\n(MCP Server & CLI)"]
end
subgraph Kaggle["Kaggle Cloud Container (2x Tesla T4 — Up to 12h)"]
Boot["bootstrap_worker.py\n(via kaggle kernels push)"]
Tunnel["Auto-Healing Tunnel\n(Cloudflared / Optional Tailscale)"]
Daemon["Stdlib RPC Daemon\n(256-bit Bearer HMAC)"]
PTY["Stateful Bash PTY"]
Jobs["Detached GPU Jobs\n(/kaggle/working/mcp_logs)"]
Dog["Watchdogs\n(11h40m Drain + Idle Guard)"]
end
Agent <-->|"MCP stdio"| MCP
MCP -->|"1. Push private kernel"| Boot
Boot --> Tunnel & Daemon & Dog
Tunnel -.->|"2. Private Dataset Handshake\n(<user>/kaggle-mcp-state)"| MCP
MCP <-->|"3. Authenticated HTTPS RPC"| Tunnel
Daemon --> PTY & JobsQuickstart (60 Seconds)
1. Install
git clone https://github.com/NguyenQuocDat06-AI/kaggle-shell-mcp.git
cd kaggle-shell-mcp
python -m venv .venv
# Windows
.\.venv\Scripts\pip install -e .
# Linux / macOS
./.venv/bin/pip install -e .2. Add Your Kaggle Token
Create a .env file in the project root (or pass environment variables directly in your MCP config):
KAGGLE_USERNAME=your_kaggle_username
KAGGLE_KEY=KGAT_your_api_token_here(Get your token from kaggle.com/settings → API → Generate New Token. Make sure your Kaggle account is phone-verified so GPU accelerators are unlocked.)
3. Connect Your AI Agent (MCP)
Claude Desktop / Cursor / Antigravity (mcp_config.json)
{
"mcpServers": {
"kgsh": {
"command": "/absolute/path/to/kaggle-shell-mcp/.venv/bin/kgsh",
"args": [],
"env": {
"KAGGLE_USERNAME": "your_kaggle_username",
"KAGGLE_KEY": "KGAT_your_api_token_here"
}
}
}
}(On Windows, point "command" to C:/path/to/kaggle-shell-mcp/.venv/Scripts/kgsh.exe. If .env is placed in the repo root, the "env" block is optional.)
Claude Code CLI
claude mcp add kgsh -- /absolute/path/to/kaggle-shell-mcp/.venv/bin/kgshMCP Tools Reference
Tool | Purpose |
| Provision a headless Kaggle Dual-T4 worker ( |
| Inspect kernel status, live Dual-T4 GPU/VRAM %, RAM, |
| Gracefully terminate the worker ( |
| Run bash commands in a persistent stateful PTY ( |
| Start long-running GPU training/inference in an isolated process group immune to disconnects |
| List active and completed background jobs with PID, runtime, exit code, and log size |
| Read tail lines of a job log (with regex |
| Send |
|
|
Standalone CLI Usage (kgsh)
Invoke kgsh with no arguments to run the MCP stdio server, or pass subcommands directly from your terminal:
# Check status (costs 0 GPU quota)
kgsh status
# Boot a Dual-T4 GPU session (~50s cold start; add --idle 30 for optional idle auto-shutdown)
kgsh up
# Run interactive commands (stateful PTY)
kgsh exec "nvidia-smi"
kgsh push ./my_project /kaggle/working
# Launch a multi-GPU training job across both T4 GPUs (30 GB total VRAM)
kgsh spawn "torchrun --nproc_per_node=2 my_project/train.py" --name lora-run
kgsh jobs
kgsh logs <job_id> --tail 50
# Pull checkpoints & shut down immediately to save quota
kgsh pull /kaggle/working/checkpoints ./checkpoints
kgsh downChaining Runs Longer Than 12 Hours
Save periodic checkpoints into
/kaggle/working/checkpoints/inside your training script (and handleSIGTERMif desired for the11h35mdrain hook).After Session 1 exits cleanly at
11h40m, start Session 2 withchain_previous_output=True(orkgsh up --chain). Kaggle mounts Session 1's output directly under/kaggle/input/kaggle-mcp-worker/at internal datacenter speeds.
Responsible Use
kaggle-shell-mcp is built for legitimate machine learning experimentation, model training, and data science workflows on your own Kaggle account. Respect Kaggle's Terms of Service: do not use Kaggle notebooks for crypto-mining, public web hosting, or network proxying, and shut down sessions with kaggle_down (or set optional idle_timeout_min) when finished so GPUs return to the community pool promptly.
License
Released under the MIT License.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
On-demand GPU nodes for agents: create nodes, run commands, and submit jobs, billed by the minute.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
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
- AlicenseNot gradedqualityFmaintenanceEnables AI agents and CLI users to drive Kaggle notebooks end-to-end—pull, edit, save new versions, run, monitor, and fetch logs—using a local stdio MCP server with a Kaggle API token.MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with Kaggle through MCP, including remote GPU/TPU kernel execution, competition and dataset downloads, and kernel management via SSE.-
- AlicenseAqualityBmaintenanceEnables local coding agents to manage disposable Colab GPU runtimes, restore and save Google Drive checkpoints, execute scripts, and safely stop VMs through MCP stdio tools.12MIT