lattice-mcp-server
by nesar
README.md
# lattice-qcd-server
[](https://github.com/nesar/lattice-qcd-server/actions/workflows/ci.yml)
`analysis` `nuclear-physics` · part of the [HEP-KE MCP server library](https://hep-ke.github.io/hep-servers/)
An MCP server that exposes science tools - the thermodynamics of hot,
strongly interacting matter from lattice QCD - to any LLM agent: the HotQCD
equation of state, the hadron resonance gas, HRG baryon-number
fluctuations and the running strong coupling, all computed with the
LatticeQCD AnalysisToolbox. Built on the same pattern as
[`power-spectrum-server`](https://github.com/HEP-KE/power-spectrum-server) and
[`gaia-data-server`](https://github.com/HEP-KE/gaia-data-server); the
multi-agent client in
[`multiagent-client-demo`](https://github.com/HEP-KE/multiagent-client-demo)
drives any of these servers unchanged.
## At a glance
| | |
|---|---|
| Category | analysis |
| Domain | nuclear physics |
| HPC dispatch | no |
| Skill prefix | `lattice` (`list_lattice_skills`, `load_lattice_skill`) |
| Default port | `8005` (streamable-http) |
| Hosted endpoint | none |
## The science
Heat nuclear matter past about 156 MeV (~2 × 10¹² K) and hadrons dissolve
into a quark–gluon plasma. This is not speculation: it is a first-principles
result of lattice QCD, it is recreated on Earth in heavy-ion collisions at
RHIC and the LHC, and the universe itself cooled through this transition
about 10 μs after the Big Bang. The tools here compute the two descriptions
that meet at the crossover:
- the **equation of state** of QCD matter — the published parameterization of
continuum-extrapolated (2+1)-flavor lattice results (Bazavov et al.,
HotQCD collaboration, [PRD 90, 094503 (2014)](https://arxiv.org/abs/1407.6387)),
- the **hadron resonance gas** (HRG) — a non-interacting gas of ~1200 hadrons
and resonances (QMHRG2020 list), the confined-phase description that must
fail once quarks are liberated.
Where the dashed HRG curves peel away from the lattice curves *is*
deconfinement:

Everything is computed with the
[**LatticeQCD AnalysisToolbox**](https://github.com/LatticeQCD/AnalysisToolbox)
(`pip install latqcdtools`), the HotQCD collaboration's public analysis
package. The hadron list bundled in `data/` comes from that repository (MIT
license).
A question to ask an agent:
> "At what temperature does hadronic matter melt? Compute the lattice QCD
> equation of state and the hadron resonance gas, overlay them, and tell me
> where and why they disagree."
## Tools
| tool | what it does |
|---|---|
| `list_lattice_skills` / `load_lattice_skill` | server-side skills (also served as MCP prompts) |
| `describe_qcd_thermodynamics()` | physics context, validity ranges, references — call it first |
| `compute_qcd_eos(output_dir, ...)` | lattice EoS: p/T⁴, ε/T⁴, s/T³, trace anomaly, c_s² on a T grid → CSV |
| `compute_hrg_thermodynamics(output_dir, ...)` | the same columns from the hadron resonance gas → CSV |
| `plot_qcd_eos(eos_file, output_dir, hrg_file=None, save_pdf=False)` | the classic ε/T⁴, 3p/T⁴, (3/4)s/T³ figure, T_pc band, Stefan–Boltzmann limit, optional HRG overlay |
| `plot_qcd_speed_of_sound(eos_file, output_dir, hrg_file=None, save_pdf=False)` | c_s²(T) with the softest point + trace-anomaly panels |
| `compute_hrg_baryon_cumulants(output_dir, ...)` | HRG baryon-number susceptibilities χ₂ᴮ, χ₄ᴮ (heavy-ion fluctuation observables) → CSV |
| `plot_hrg_baryon_cumulants(cumulants_file, output_dir, save_pdf=False)` | χₙᴮ(T) and χ₄ᴮ/χ₂ᴮ between the hadron-gas (1) and free-quark (2/3π²) values |
| `compute_qcd_running_coupling(output_dir, ...)` | 2-loop α_s(μ): asymptotic freedom → CSV + PNG |
Every tool name carries a `qcd`/`hrg` token so agents connected to several
HEP-KE servers cannot confuse it with, e.g., the cosmology "equation of
state" w. Output file names include a short hash of the inputs, so scans
(several μ_B/T or T ranges) never overwrite each other. Figures use
matplotlib's built-in STIX mathtext (no LaTeX install needed), a
colorblind-validated palette paired with line styles, and can also be saved
as vector PDF.
Two conventions shared by every HEP-KE server:
1. Every tool returns `{status, files, message, metadata}` (`ArtifactResult`).
2. Arrays move between tools **as file paths**, never through the agent's
context window.
## Skills
| skill | use it to |
|---|---|
| `lattice-tour` | a guided first run through every tool, with the numbers to expect |
| `qcd-deconfinement-crossover` | locate the crossover: lattice EoS vs HRG, c_s² softest point, trace-anomaly peak |
| `hrg-fluctuations-beam-energy-scan` | scan HRG χ₂ᴮ, χ₄ᴮ over μ_B/T and frame them between hadron-gas and free-quark values |
## Install and run
```bash
git clone https://github.com/nesar/lattice-qcd-server.git && cd lattice-qcd-server
uv sync # creates this server's own .venv from uv.lock
./run_server.sh # stdio (what agent clients launch)
./run_server.sh --transport streamable-http --port 8005 # URL endpoint at http://127.0.0.1:8005/mcp
```
The default port is now **8005** (from `[tool.mcp-server].port`; it was 8002
in the tutorial version). Stop with **Ctrl+C**. Every server has its own
`.venv`, so the package names `tools` and `mcp_server` shared by all HEP-KE
servers never collide.
Without uv: `python -m venv .venv && .venv/bin/pip install -e ".[dev]"`
(Python ≥ 3.11), then `./run_server.sh` as above.
## Connect a client
Claude Code (from the repo directory, `.mcp.json` is picked up automatically):
```bash
claude mcp add lattice -- /path/to/lattice-qcd-server/run_server.sh
```
Claude Desktop, Codex, ChatGPT, Antigravity and hep-genesis-agent: see
[the library site](https://hep-ke.github.io/hep-servers/#connect) and
[`docs/mcp-clients.md`](docs/mcp-clients.md).
## Development and tests
```bash
uv sync --extra dev
uv run ruff check .
uv run pytest -m "not network and not slow" # contract + science tests (what CI runs)
uv run pytest -m network # tests that download public data (none here)
uv run python tests/smoke_server.py # live stdio server: lists tools and prompts
```
Science tests (`tests/test_qcd.py`) check the HotQCD EoS against published
values (arXiv:1407.6387), HRG vs lattice agreement below T_pc, α_s(M_Z),
file round trips and that latqcdtools does not leak its warning filters.
The generic files (`mcp_server/`, `tools/meta/`, `tests/test_contract.py`,
`tests/smoke_server.py`, CI) come from the HEP-KE MCP server standard; do not
edit them per server. Science code lives in `tools/qcd/`.
## Limitations
- The HotQCD parameterization carries no uncertainties (published lattice
errors are a few %); valid for 130 ≤ T ≤ 400 MeV at μ_B = 0 only.
- In the (Boltzmann) HRG χ₄ᴮ/χ₂ᴮ = 1 exactly, and no lattice cumulant data
are bundled — the free-quark value 2/(3π²) ≈ 0.068 is drawn as the
deconfined reference. Quote lattice / STAR / ALICE values from the
literature.
- α_s is two-loop with fixed n_f (no flavour thresholds).
## Citation and license
- Bazavov et al. (HotQCD), PRD 90, 094503 (2014), arXiv:1407.6387 — equation of state.
- Bollweg et al. (HotQCD), PRD 104, 074512 (2021), arXiv:2107.10011 — QMHRG2020 hadron list.
- HotQCD, PLB 795 (2019) 15, arXiv:1812.08235 — crossover temperature.
- [LatticeQCD AnalysisToolbox](https://github.com/LatticeQCD/AnalysisToolbox) (MIT).
Code: MIT, see [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessLimited data