slurm-mcp
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.
slurm-mcp — SLURM MCP Server for Claude Code
Author: Samuel Ahuno (ekwame001@gmail.com), Greenbaum Lab, MSKCC License: MIT Date: 2026-02-21
A Model Context Protocol (MCP) server that gives Claude Code native access to SLURM job management. Submit, monitor, and cancel jobs without leaving the conversation.
Quick Start (3 steps)
1. Clone and install
git clone https://github.com/ahunos/slurm-mcp.git # or copy from shared location
cd slurm-mcp
pip install -e .Or install into an existing conda/venv:
conda activate myenv # or: source myenv/bin/activate
pip install -e /path/to/slurm-mcp2. Run the setup script
bash setup.shThis will:
Detect your Python path, SLURM account, and default partition
Generate a partition resource limits profile (
~/.slurm-mcp/partition_limits_latest.json)Validate your default resources against the selected partition's actual limits
Ask you to confirm or change each value
Write the MCP server config into
~/.claude.json
If you prefer to configure manually, see Manual Configuration below.
3. Restart Claude Code
# Exit any running Claude Code session, then relaunch:
claudeThe SLURM tools will appear automatically. Try asking Claude:
"List my running SLURM jobs"
Related MCP server: tacc-mcp-bio
Tools Provided
Tool | Description |
| Submit a script or |
| Check status of one or more jobs (squeue + sacct) |
| List all jobs for the current user |
| Read stdout/stderr logs for a job |
| Cancel a running or pending job |
| Get resource usage for a completed job |
| Show partition availability and limits |
| Per-node resource availability (free RAM, free CPUs, load) |
| Submit multiple scripts, optionally chained |
Validation modes
Before submitting, you can validate your job at two levels:
Parameter | What it does | Talks to SLURM? |
| Returns the sbatch command without running it | No |
| Asks the SLURM scheduler to validate (partition, resources, account, estimated start time) without creating a job | Yes |
Manual Configuration
If you skipped setup.sh, add this block to your ~/.claude.json. Replace
the placeholder values with your own:
{
"mcpServers": {
"slurm": {
"type": "stdio",
"command": "<YOUR_PYTHON_PATH>",
"args": ["-m", "slurm_mcp.server"],
"env": {
"SLURM_DEFAULT_ACCOUNT": "<YOUR_SLURM_ACCOUNT>",
"SLURM_DEFAULT_PARTITION": "<YOUR_DEFAULT_PARTITION>",
"SLURM_DEFAULT_NODES": "1",
"SLURM_DEFAULT_NTASKS_PER_NODE": "1",
"SLURM_DEFAULT_CPUS_PER_TASK": "8",
"SLURM_DEFAULT_MEM": "64G",
"SLURM_DEFAULT_TIME": "04:00:00",
"SLURM_LOG_DIR": "<YOUR_HOME>/slurm_logs",
"SLURM_MAX_CPUS": "64",
"SLURM_MAX_MEM_GB": "256",
"SLURM_MAX_TIME_HOURS": "168",
"SLURM_MAX_GPUS": "4",
"SLURM_PARTITION_LIMITS": "<YOUR_HOME>/.slurm-mcp/partition_limits_latest.json"
}
}
}
}To find each value:
which python3 # → YOUR_PYTHON_PATH
sacctmgr show assoc user=$USER -p | head # → YOUR_SLURM_ACCOUNT (Account column)
sinfo -s | head # → YOUR_DEFAULT_PARTITION
echo $HOME # → YOUR_HOMEEnvironment Variables
Variable | Default | Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Default memory per job |
|
| Default wall time |
|
| Where stdout/stderr logs are written |
|
| Safety limit: max CPUs per job |
|
| Safety limit: max memory (GB) |
|
| Safety limit: max wall time (hours) |
|
| Safety limit: max GPUs per job |
|
| Path to partition limits JSON (generated by |
Safety Guardrails
The server validates every submission against configurable limits before calling sbatch. Requests exceeding any limit are rejected with a clear error.
Per-partition limits: When a partition limits profile is loaded (
SLURM_PARTITION_LIMITS), validation uses the actual max CPUs, memory, time, and GPUs for the target partition. Requesting GPUs on a CPU-only partition is caught before submission.Global fallback limits: CPU, memory, time, and GPU limits apply when no partition profile is available.
Optional partition allowlist (
SLURM_ALLOWED_PARTITIONS)Audit log at
~/slurm_logs/audit.jsonl(every submit/cancel is recorded)
Optional: PostToolUse Hook (Submission Logging)
You can add a Claude Code hook to automatically log every SLURM submission to a
human-readable markdown file. Add this to ~/.claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "mcp__slurm__slurm_submit_job",
"command": "~/.claude/hooks/log-slurm-submission.sh"
}
]
}
}See ~/.claude/hooks/log-slurm-submission.sh for the hook script.
Each entry records: timestamp, job ID, job name, sbatch command, and status.
Known Bugs and Gotchas
1. SLURM $0 resolves to /var/spool/slurmd/ in batch scripts
Problem: When sbatch runs a script, it copies the script to a SLURM spool
directory (e.g. /var/spool/slurmd/job12345/slurm_script). If your script
uses dirname "$0" to find its own location (a common pattern for setting
BASE_DIR), it will resolve to /var/spool/slurmd/ instead of the original
script directory. Any mkdir or file writes relative to that path fail with
Permission denied.
Symptom: Jobs fail in ~2 seconds with:
mkdir: cannot create directory '/var/spool/slurmd/logs': Permission denied
mkdir: cannot create directory '/var/spool/slurmd/data': Permission deniedFix: Use SLURM_SUBMIT_DIR (set by sbatch to the directory where sbatch
was invoked) or pass the base directory as a positional argument:
# BAD — breaks under SLURM
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
# GOOD — SLURM-safe with fallback
BASE_DIR="${1:-${SLURM_SUBMIT_DIR:-$(cd "$(dirname "$0")/.." && pwd)}}"When submitting via the MCP server, prefer --wrap with an explicit argument:
wrap: bash /path/to/script.sh /path/to/base_dir2. Account/partition must be specified
Problem: On MSKCC's cluster, omitting --account causes:
sbatch: error: Batch job submission failed: Invalid account or account/partition combination specifiedFix: Set SLURM_DEFAULT_ACCOUNT=greenbab and
SLURM_DEFAULT_PARTITION=componc_cpu in the MCP config. The server
automatically injects --account into every sbatch call.
3. MCP server must be restarted to pick up config changes
After editing ~/.claude.json, you must restart Claude Code (exit and
relaunch) for the MCP server to pick up new environment variables.
Project Structure
slurm-mcp/
setup.sh # Interactive setup (detects account, partition, generates limits)
pyproject.toml # Package metadata, dependencies
LICENSE # MIT
src/slurm_mcp/
__init__.py
server.py # MCP tool/resource definitions (FastMCP)
slurm_cli.py # SLURM CLI wrappers + partition-aware validation
tests/
test_slurm_mcp.py # 74 tests (all mocked, no real SLURM needed)
docs/
devlog.md # Development journal
job_resource_profiles.md # Comp-bio job classification (Q1-Q4 resource profiles)Testing
cd slurm-mcp
pytest tests/ --tb=short # 74 tests, no real SLURM needed (all mocked)How It Works
Claude Code spawns the server as a subprocess via stdio transport
The server exposes SLURM tools via the Model Context Protocol
Claude calls tools like
mcp__slurm__slurm_submit_jobwith parametersThe server validates resources, builds an sbatch command, and executes it
Results (job ID, log paths, etc.) are returned as JSON
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
Deploy, monitor, and manage your OpenClaw AI assistants via natural language.
AI code governance and code review for Claude Code, Copilot and Cursor. Checks rules and security.
Build, validate, test-run and publish AIOS workflows from Claude Code, Codex, Cursor or VS Code.
Live SEO workflow tools for Claude Code, Codex, and AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Slurm HPC clusters via SSH, allowing job submission, monitoring, and error diagnosis through MCP clients like Claude Desktop.6MIT
- FlicenseNot gradedqualityDmaintenanceEnables Claude Code to interact with a TACC or SLURM HPC cluster for bioinformatics pipelines, allowing job management, log reading, file browsing, remote script execution, and job submission through natural language.-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage SLURM HPC clusters via SSH. Supports job submission, resource monitoring, queue management, and file operations.4-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage SLURM cluster jobs with safety guardrails, including file transfer, job submission, log reading, and remote command execution.1MIT