AI Interfaces

Chimera MCP and ChimeraSandbox

The Model Context Protocol (MCP) allows an AI client such as OpenCode to use tools provided by external processes. Two MCP-based options are available for working with Chimera, but they serve different purposes:

Project Purpose Execution model
ChimeraMCP Guarded access to Slurm, jobs, logs, user-scoped files, and archive operations OpenCode starts the installed MCP servers over SSH; submitted compute runs through Slurm
ChimeraSandbox A persistent Apptainer environment with shell and file tools for CPU/GPU workloads A Slurm job holds an Apptainer instance on a compute node and OpenCode attaches to it

ChimeraSandbox is the user-facing name used in this documentation. Its OpenCode configuration key remains apptainer-mcp.

ChimeraMCP

ChimeraMCP currently provides two MCP servers through the administrator-managed chimera-mcp module:

  • chimera-slurm-mcp discovers cluster resources and accounts; inspects jobs, arrays, accounting, efficiency, and logs; submits guarded template or script jobs; and controls jobs owned by the current user.
  • chimera-filecompress-mcp safely plans, creates, and extracts zip and tar-family archives. Large archive operations can be routed through Slurm.

The active tools and permitted paths depend on the server configuration and security level. Filesystem operations are restricted to configured roots, and job details and control operations are restricted to jobs owned by the connected user. ChimeraMCP is a policy-enforcing interface, not a general runtime sandbox.

Check the installation

Log in to Chimera and confirm that the module exposes both commands:

ssh USER@hpc.troja.mff.cuni.cz
module load chimera-mcp
which chimera-slurm-mcp
which chimera-filecompress-mcp

Replace USER with your lowercase Chimera/CAS login. Configure key-based SSH authentication before using BatchMode=yes, because OpenCode cannot answer an interactive password prompt from an MCP subprocess.

Add ChimeraMCP to OpenCode

OpenCode reads global configuration from ~/.config/opencode/opencode.jsonc or project configuration from opencode.jsonc in the project root. Merge the following mcp entries into that file and replace USER:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "chimera-slurm": {
      "type": "local",
      "command": [
        "ssh",
        "-T",
        "-o", "BatchMode=yes",
        "-o", "LogLevel=ERROR",
        "USER@hpc.troja.mff.cuni.cz",
        "bash -lc 'module load chimera-mcp && exec chimera-slurm-mcp'"
      ],
      "enabled": true,
      "timeout": 600000
    },
    "chimera-filecompress": {
      "type": "local",
      "command": [
        "ssh",
        "-T",
        "-o", "BatchMode=yes",
        "-o", "LogLevel=ERROR",
        "USER@hpc.troja.mff.cuni.cz",
        "bash -lc 'module load chimera-mcp && exec chimera-filecompress-mcp'"
      ],
      "enabled": true,
      "timeout": 600000
    }
  }
}

Keep each complete bash -lc '...' expression as one item in the command array. After restarting OpenCode, verify the connections with:

opencode mcp list

For reusable OpenCode agent and skill templates, see the ChimeraMCP OpenCode HPC Agent project. The complete server reference, configuration rules, and security model are maintained in the ChimeraMCP documentation.

ChimeraSandbox (experimental)

ChimeraSandbox runs the apptainer-mcp server inside a persistent Apptainer instance on a Slurm compute node. It gives an OpenCode agent four tools:

Tool Purpose
bash Run shell commands inside the container
read_file Read a size-limited file
write_file Create or overwrite a file
list_dir List a directory

The submitted project directory is mounted at /workspace, which is the intended location for inputs, environments, checkpoints, logs, and results. Container state and background processes survive OpenCode reconnects while the Slurm job remains alive. Only data stored on a persistent host filesystem, including the mounted /workspace, survives the end of the allocation.

This workflow is experimental. Unlike ChimeraMCP, its bash and file tools do not enforce guarded Slurm, path, or owned-job policies. Commands run with the permissions of your cluster account, and /workspace contains real user data. Review requested operations accordingly.

The ChimeraSandbox image is not publicly available. If you want to use ChimeraSandbox, contact the Chimera administrators or the RSE team. We will provide the required image and the connection details on request.

Add ChimeraSandbox to OpenCode

After the ChimeraSandbox job has been started for you, add the provided apptainer-mcp entry to the mcp object in your global or project OpenCode configuration. It has this form:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "apptainer-mcp": {
      "type": "local",
      "enabled": true,
      "command": [
        "ssh", "-T", "USER@hpc.troja.mff.cuni.cz",
        "srun", "--jobid=JOBID", "--overlap",
        "apptainer", "exec", "instance://agent",
        "python", "-u", "/opt/mcp/server.py"
      ]
    }
  }
}

Replace USER and JOBID with the connection details provided by the Chimera team. Restart OpenCode and check the connection with opencode mcp list. A useful first request is to run hostname, nvidia-smi, pwd, and python --version through the sandbox bash tool.

Closing or restarting OpenCode does not release the Slurm allocation. The requested CPUs, memory, and GPU remain reserved until the job reaches its wall-time or is canceled. When finished, remove or disable the stale OpenCode entry and release the resources:

scancel JOBID