This guide walks through setting up OpenCode to use ChemGraph as an MCP (Model Context Protocol) tool server on ALCF systems such as Aurora. With this setup, you can use natural-language prompts inside OpenCode to run computational chemistry workflows (geometry optimizations, vibrational analyses, thermochemistry calculations and more) on ALCF compute nodes.
Everything runs from an Aurora login node. Two SSH tunnels provide connectivity to the Argo LLM API and the ChemGraph MCP server on a compute node:
Argo API Aurora Login Node Compute Node
(apps-dev.inside.anl.gov) (you are here)
┌───────────────┐ ┌────────────┐ ┌───────────────┐
│ Argo LLM │◄── SSH ──┤ ├──── SSH ────►│ ChemGraph │
│ Gateway │ Tunnel │ OpenCode │ Tunnel │ MCP Server │
│ :443 │ (8443) │ │ (9003) │ (port 9003) │
└───────────────┘ └────────────┘ └───────────────┘
| Tunnel | Purpose | Endpoint |
|---|---|---|
| Port 8443 | Argo LLM API gateway | apps-dev.inside.anl.gov:443 |
| Port 9003 | ChemGraph MCP server | Compute node MCP process |
- ChemGraph installed on ALCF — see
scripts/mcp_example/installation.mdfor Aurora-specific instructions. - OpenCode installed on the Aurora login node — see https://opencode.ai/docs/installation.
- SSH access from the Aurora login node to an Argonne machine with Argo API access (for the Argo tunnel).
- Allocation on an ALCF system (Aurora, Polaris, etc.) to request compute nodes.
On the Aurora login node, create (or update) the OpenCode user
configuration file at ~/.config/opencode/opencode.json. This tells OpenCode
how to reach the Argo LLM API:
Key fields:
| Field | Description |
|---|---|
baseURL |
Points to 127.0.0.1:8443 on the login node — the local end of the SSH tunnel to Argo (see Step 2). The port must match your SSH -L port. |
apiKey |
Your ANL username. |
Host header |
Routes traffic to the correct backend (apps-dev.inside.anl.gov). |
models |
Available LLMs via Argo. |
lsp.pyright |
Required. Enables Python language server support in OpenCode. Update the path to match your pyright-langserver location. |
From the Aurora login node, open a terminal and create an SSH tunnel to the Argo API gateway through an Argonne machine that has Argo access:
ssh -L 8443:apps-dev.inside.anl.gov:443 <your_argonne_machine_with_Argo_access> -N-L 8443:apps-dev.inside.anl.gov:443forwards login-node port8443to the Argo endpoint.-Nkeeps the connection open without starting a shell.- This tunnel must remain active while you use OpenCode.
Note: The port number (
8443) must match the port in thebaseURLfield of your~/.config/opencode/opencode.json. You can choose any available port on the login node — just keep them consistent.
The MCP server runs on an ALCF compute node so it has access to GPUs and the software stack needed for molecular simulations.
From the Aurora login node, request a compute node:
qsub -I -l select=1 -l walltime=01:00:00 -l filesystems=home:flare -q debug -A <your_project>A convenience script is provided in this directory:
./start_mcp_interactive.sh --venv /path/to/your/chemgraph/venv --port 9003The script will:
- Set ALCF proxy variables and load the
frameworksmodule. - Activate the specified virtual environment.
- Start the ChemGraph MCP HTTP server on the given port.
- Wait for the server to become ready and print connection instructions.
- Tail the server log until you press
Ctrl+C.
Script options:
| Option | Default | Description |
|---|---|---|
--port PORT |
9003 |
Port for the MCP HTTP server |
--venv PATH |
(none) | Path to the Python virtual environment |
--log-dir PATH |
./chemgraph_mcp_logs |
Directory for server logs |
--mcp-module MOD |
chemgraph.mcp.mcp_tools |
Python module to run as the MCP server |
Take note of the compute node hostname as you will need it for the next step.
From a second terminal on the Aurora login node, tunnel port 9003 to the compute node:
ssh -N -L 9003:localhost:9003 <compute_node_id>Replace <compute_node_id> with the hostname from Step 3.
This forwards login-node port 9003 to the MCP server running
on the compute node.
Copy the provided opencode.jsonc into your ChemGraph
project working directory (the directory where you will run opencode):
cp examples/OpenCode/opencode.jsonc /path/to/your/working/directory/opencode.jsonOr, if you are already in the ChemGraph root:
cp examples/OpenCode/opencode.jsonc ./opencode.jsonThe MCP config tells OpenCode where to find the ChemGraph MCP server:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"chemgraph": {
"type": "remote",
"url": "http://localhost:9003/mcp/",
"enabled": true,
"headers": {
"Authorization": "Bearer MY_API_KEY"
}
}
}
}Note: The
urlport (9003) must match the port used in the SSH tunnel and the--portargument tostart_mcp_interactive.sh. The project root already contains anopencode.jsonfor local (stdio) MCP usage. The config in this example is for remote (HTTP) MCP via port forwarding.
With both SSH tunnels active on the login node (Argo on port 8443, MCP on port 9003), open a third terminal on the Aurora login node and start OpenCode in your working directory:
opencodeOpenCode will:
- Load the user config from
~/.config/opencode/opencode.json(Argo provider). - Detect the project-level
opencode.jsonand connect to the ChemGraph MCP server. - Display available MCP tools (e.g.,
molecule_name_to_smiles,run_ase,smiles_to_coordinate_file,extract_output_json).
You can verify the MCP connection by pressing ctrl+p and checking that the
ChemGraph tools are listed.
Once connected, try these prompts inside OpenCode:
What is the enthalpy of CO2 using MACE at 500K?
Optimize the geometry of aspirin using MACE-MP medium model.
Calculate the vibrational frequencies of water using TBLite GFN2-xTB.
All terminals below are on the Aurora login node:
| Terminal | Command | Purpose |
|---|---|---|
| 1 | ssh -L 8443:apps-dev.inside.anl.gov:443 <argo_host> -N |
Tunnel to Argo LLM API |
| 2 | qsub -I ... then ./start_mcp_interactive.sh ... |
Start MCP server on compute node |
| 3 | ssh -N -L 9003:localhost:9003 <compute_node> |
Tunnel to MCP server |
| 4 | opencode |
Launch OpenCode |
If you encounter 503 errors or proxy-related failures, unset the proxy environment variables on the login node before running OpenCode:
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY- Check the log file printed by
start_mcp_interactive.sh(in./chemgraph_mcp_logs/). - Ensure ChemGraph is installed correctly:
python -c "import chemgraph". - Verify the virtual environment path passed to
--venvis correct.
- Confirm the SSH tunnel (port 9003) is active on the login node.
- Verify the compute node hostname matches what you used in the SSH tunnel.
- Test the endpoint from the login node:
curl http://localhost:9003/mcp/.
- Confirm the SSH tunnel (port 8443) is active.
- Verify your ANL username is set as the
apiKeyin the OpenCode config.
- Dr. Neil Getty (ANL) for the config for OpenCode on ALCF machines to Argo API.
{ "$schema": "https://opencode.ai/config.json", "provider": { "argo": { "npm": "@ai-sdk/openai-compatible", "name": "Argo", "options": { "baseURL": "https://127.0.0.1:8443/argoapi/v1", "apiKey": "<ANL Username>", "headers": { "Authorization": "Bearer custom-token", "Host": "apps-dev.inside.anl.gov" } }, "models": { "gpt52": { "name": "GPT-5.2" }, "claudeopus46": { "name": "Claude Opus 4.6", }, "claudesonnet46": { "name": "Claude Sonnet 4.6", }, "claudesonnet45": { "name": "Claude Sonnet 4.5", }, "claudehaiku45": { "name": "Claude Haiku 4.5", } } } }, "lsp": { "pyright": { "command": ["/home/<ANL Username>/.local/bin/pyright-langserver", "--stdio"], "extensions": [".py", ".pyi"] } } }