Secure Cluster MCP
Let AI coding assistants manage your SLURM cluster jobs safely.
Built with FastMCP for ML researchers who want seamless experiment management through Claude Code or other MCP-compatible agents.
Why?
Running ML experiments on HPC clusters typically means manual scp/ssh commands. This MCP server lets your AI assistant handle the workflow - transferring code, submitting jobs, monitoring progress, debugging failures - with built-in safety guardrails.
- Structure - well-defined tools for common workflows (transfer, submit, read logs)
- Guardrails - path validation, rate limiting, dangerous command blocking
- Permissions - read-only tools auto-allowed, write operations require confirmation
Recommended Claude Code permissions
In settings.local.json, auto-allow read-only tools:
{
"permissions": {
"allow": [
"mcp__cluster__cluster_info",
"mcp__cluster__list_remote",
"mcp__cluster__check_queue",
"mcp__cluster__read_logs",
"mcp__cluster__search_logs"
]
}
}
Tools requiring permission (write/execute): transfer_file, download_file, submit_job, poll_job, run_remote_command, singularity_test
Prerequisites
- SSH access to your cluster (key-based authentication)
- SLURM scheduler (sbatch, squeue commands)
Guardrails
- Rate limiting - max 30 commands per 5 min (configurable via env)
- Path validation - all paths must be under REMOTE_BASE_PATH
- Dangerous command blocklist - blocks
rm -rf,mkfs, fork bombs, etc. - DRY_RUN mode - set
DRY_RUN=trueto log commands without executing
Installation
# From GitHub
pip install git+https://github.com/FlorianSp2000/secure-cluster-mcp.git
# Or clone and install locally
git clone https://github.com/FlorianSp2000/secure-cluster-mcp.git
cd secure-cluster-mcp
pip install -e .
Configuration
Copy .env.example to .env and edit:
cp .env.example .env
Required settings:
CLUSTER_HOST=your.cluster.ip # Cluster IP or hostname
CLUSTER_USER=your_username # Your cluster username
REMOTE_BASE_PATH=/home/user/project/ # Your working directory on cluster
SSH_KEY_PATH=~/.ssh/your_key # Path to SSH private key
Optional settings:
DRY_RUN=false # Set true to log without executing (default: false)
LOG_DIR=logs # Log subdirectory for job output (default: logs)
RATE_LIMIT_COMMANDS=30 # Max commands per window (default: 30)
RATE_LIMIT_WINDOW_SECONDS=300 # Rate limit window in seconds (default: 300)
LOG_TAIL_LINES=200 # Default lines to read from logs (default: 200)
Claude Code Integration
Add to ~/.claude/settings.json or .claude/settings.local.json:
If installed via pip:
{
"mcpServers": {
"cluster": {
"command": "secure-cluster-mcp"
}
}
}
If running from cloned repo (development):
{
"mcpServers": {
"cluster": {
"command": "uv",
"args": ["--directory", "/path/to/secure-cluster-mcp", "run", "secure-cluster-mcp"]
}
}
}
Available Tools
| Tool | Description |
|---|---|
cluster_info |
Show connection info and settings |
transfer_file |
Upload local file to cluster |
download_file |
Download file from cluster to local |
submit_job |
Submit sbatch script |
check_queue |
List user's jobs in SLURM queue |
poll_job |
Wait for job completion |
read_logs |
Read job stdout/stderr (tail) |
list_remote |
List files with time filtering (mmin/mtime) |
search_logs |
Grep log files with time filtering |
run_remote_command |
Execute command on login node |
singularity_test |
Test container on login node (no GPU, 60s cap) |
Prompts
Pre-defined workflows for common tasks:
| Prompt | Description |
|---|---|
check_failed_jobs(hours) |
Find errors in recent logs, summarize failures |
submit_array_job(script, range) |
Guide for submitting array jobs |
cluster_status() |
Overview of queue and recent job status |
debug_job(job_id) |
Debug a specific job's stdout/stderr |
Time filtering with list_remote and search_logs
Both tools support time-based filtering:
mmin=N- files modified within last N minutesmtime=N- files modified within last N days
# List .err files from last 24h
list_remote("logs", pattern="*.err", mtime=1)
# Search for errors in logs from last 6 hours
search_logs("Error", mmin=360)
Notes on read_logs
Can read any file under REMOTE_BASE_PATH:
# By job ID - uses LOG_DIR
read_logs("12345") # → {REMOTE_BASE_PATH}/{LOG_DIR}/12345.out
# By full path
read_logs("/home/user/project/results/output.csv")
Troubleshooting
"Connection refused" or timeout
- Verify SSH access works:
ssh user@cluster_host - Check VPN connection if required
- Ensure SSH key has correct permissions:
chmod 600 ~/.ssh/your_key
"Path not under REMOTE_BASE_PATH"
- All remote paths must be under the configured REMOTE_BASE_PATH
- Check REMOTE_BASE_PATH in your .env is correct
"Rate limit exceeded"
- Wait 5 minutes or adjust RATE_LIMIT_COMMANDS
- Rate limits persist across MCP restarts
"Log file empty or not found"
- Check LOG_DIR matches your cluster's log location
- Use full path:
read_logs("/full/path/to/file.log") - Verify job ID exists:
check_queue
Commands execute but nothing happens
- Check DRY_RUN setting - must be
falsefor real execution - Review output for
[DRY_RUN]prefix
Limitations
- SLURM only - PBS/Torque/GridEngine not supported
- Unix paths - Windows cluster paths not supported
- SSH key auth - Password authentication not supported
Development
git clone https://github.com/FlorianSp2000/secure-cluster-mcp.git
cd secure-cluster-mcp
uv sync --extra dev
uv run pytest -v
License
MIT
Metadata
Release files for secure-cluster-mcp 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| secure_cluster_mcp-1.0.0.tar.gz | 113.2 kB | Without provenance | Details for secure_cluster_mcp-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| secure_cluster_mcp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for secure_cluster_mcp-1.0.0-py3-none-any.whl |
Total release size: 131.7 kB
Release files / secure_cluster_mcp-1.0.0.tar.gz
| Download URL | secure_cluster_mcp-1.0.0.tar.gz |
|---|---|
| Size | 113.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e6db3cc2fd2e274ec6a4ffb1d676261667394da057bc3d8055103845261caef
|
|
BLAKE2b-256 checksum How to use checksums |
e33bd4a21ac23083a7f1f6bda53e00fd0dcb36bb4aa03cd8039c2f6f5dcb45fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Release files / secure_cluster_mcp-1.0.0-py3-none-any.whl
| Download URL | secure_cluster_mcp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4aa7eb567e2f627ac7c9d59795f0a0f67b64d7682a2c17fbb119768db080069
|
|
BLAKE2b-256 checksum How to use checksums |
3a61f1af87d71b13c0b440d89785597b372cc82ac8f1f45e325cce315f9e99a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Security for secure-cluster-mcp 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.