MCP Servers
Note
ChemGraph exposes tools through Model Context Protocol (MCP) servers in src/chemgraph/mcp/.
Available servers
mcp_tools.py: general ASE-powered chemistry toolsmace_mcp_parsl.py: MACE + Parsl workflowsgraspa_mcp_parsl.py: gRASPA + Parsl workflowsdata_analysis_mcp.py: analysis utilities for generated results
Run a server
stdio transport (default)
streamable HTTP transport
Common CLI options
All MCP servers use:
--transportwithstdioorstreamable_http--hostfor HTTP mode--portfor HTTP mode
Docker mode
You can run MCP server mode with Docker Compose:
Endpoint: http://localhost:9003
Using with OpenCode
ChemGraph MCP tools can be used directly with OpenCode, giving you an AI coding agent with access to molecular simulation capabilities.
Quick start
-
Copy the example configuration:
-
Set
CHEMGRAPH_PYTHONto your ChemGraph Python interpreter:# Option A: a project-local venv export CHEMGRAPH_PYTHON=env/chemgraph_env/bin/python # Option B: a standard venv export CHEMGRAPH_PYTHON=.venv/bin/python # Option C: whatever environment is currently active export CHEMGRAPH_PYTHON=$(which python)Tip
Add the export to your shell profile (
~/.bashrc,~/.zshrc) so you don't have to set it every time. -
Launch OpenCode:
The
chemgraphMCP tools (molecule lookup, structure generation, ASE simulations) will be available automatically.
Available MCP servers for OpenCode
The example config (.opencode/opencode.example.jsonc) includes all servers. Enable the ones you need by uncommenting them in your opencode.json:
| Server name | Module | Tools | Status
|---|---|---|
| chemgraph | chemgraph.mcp.mcp_tools | molecule_name_to_smiles, smiles_to_coordinate_file, run_ase, extract_output_json | Stable
| chemgraph-mace-parsl | chemgraph.mcp.mace_mcp_parsl | MACE ensemble calculations via Parsl (HPC) | Experimental
| chemgraph-graspa-parsl | chemgraph.mcp.graspa_mcp_parsl | gRASPA gas adsorption via Parsl (HPC) | Experimental
| chemgraph-data-analysis | chemgraph.mcp.data_analysis_mcp | CIF splitting, JSONL aggregation, isotherm plotting | Experimental
How it works
OpenCode spawns the MCP server as a local child process using stdio transport. The {env:CHEMGRAPH_PYTHON} variable in the config is resolved at startup, so different users (or the same user on different machines) can each point to their own ChemGraph installation without modifying the committed config.
Notes for Parsl-based servers
mace_mcp_parsl.py and graspa_mcp_parsl.py rely on Parsl and HPC-specific configuration. Ensure your environment is prepared for the target system before running production jobs.