Inelastic Dark Matter MCP Server
# Inelastic Dark Matter MCP Server
[](https://github.com/nesar/inelastic-dm-server/actions/workflows/ci.yml)
`analysis` `trial` `particle-physics` `HPC` · part of the [HEP-KE MCP server library](https://hep-ke.github.io/hep-servers/)
**Q2C Bridge: Particle physics → Cosmological observables**
MCP server that connects WIMP particle physics parameters (mass, mass
splitting, cross section) to cosmological observables (recoil spectra, relic
density, indirect detection limits, CMB constraints). Motivated by the
**LZ 248 keV nuclear recoil event** (September 2026) and the **inelastic
higgsino** interpretation.
## At a glance
| | |
|---|---|
| Category | analysis, trial |
| Domain | particle physics |
| HPC dispatch | yes (IRI + Globus via hep-genesis) |
| Skill prefix | `idm` (`list_idm_skills`, `load_idm_skill`) |
| Default port | `8008` (streamable-http) |
| Hosted endpoint | none |
## The science
The server implements the following calculations — all with real formulas
from published papers, no fitting functions or placeholders:
| Calculation | Reference |
|---|---|
| Differential recoil rate (SI, inelastic) | Lewin & Smith (1996), Eq. 3.3-3.16 |
| Helm nuclear form factor | Engel (1991), Lewin & Smith Eq. 4.7-4.11 |
| Inelastic kinematics (v_min with mass splitting) | Fan & Reece, arXiv:2609.01504 |
| Thermal relic density (freeze-out) | Kolb & Turner (1990), Eq. 5.26-5.29 |
| Higgsino cross section (Z-exchange) | Fan & Reece, Eq. 8-9 |
| Fermi-LAT dSph indirect detection limits | Ackermann et al. (2015) |
| CMB energy injection constraint | Planck 2018, Slatyer (2016) |
| Annual modulation (SHM) | Freese, Frieman, Gould (1988) |
### Key result
A **thermal higgsino** at μ ≈ 1.1 TeV with mass splitting δ ≈ 300-380 keV:
- ✅ Gives correct relic density (Ω h² ≈ 0.12)
- ✅ Predicts ~1-3 events in LZ extended NR search (consistent with observation)
- ✅ Evades Fermi-LAT indirect detection (coannihilation frozen at galactic velocities)
- ✅ Evades Planck CMB energy injection bounds
### Observational data used
- **LZ**: 248 ± 23 keV nuclear recoil event (arXiv:2609.02608, September 2026)
- **Planck**: Ω_DM h² = 0.1200 ± 0.0012
- **Fermi-LAT**: dSph 95% CL limits (Ackermann et al. 2015)
- **CMB**: p_ann < 3.2×10⁻²⁸ cm³ s⁻¹ GeV⁻¹ (Planck 2018)
## Tools
Tools return a JSON string. Units: m_χ in GeV, δ and recoil energies in
keV, σ_n in cm², σv in cm³/s (0 = automatic higgsino value).
| tool | what it does |
|---|---|
| `list_idm_skills` / `load_idm_skill` | server-side skills (also served as MCP prompts) |
| `describe_tools` | Server capabilities and physics references |
| `predict_recoil` | Differential recoil spectrum for inelastic DM on xenon (HPC-dispatchable) |
| `compute_relic_density` | Thermal freeze-out Ω h² vs Planck |
| `check_all_constraints` | All constraints simultaneously (relic + LZ + Fermi + CMB) |
| `scan_mass_splitting` | (m_χ, δ) parameter space scan → `output/scan_idm.npz` (HPC-dispatchable) |
| `predict_annual_modulation` | Seasonal rate variation for inelastic DM (HPC-dispatchable) |
| `plot_recoil_spectrum` | Generate spectrum plot (PNG) |
| `plot_constraint_summary` | Combined exclusion plot from scan (PNG) |
| `set_dispatch` / `get_dispatch` / `auth_status` / `export_dispatch_pack` | HPC dispatch (see [Run on HPC](#run-on-hpc)) |
Project structure:
```
tools/
nuclear.py — Recoil rates, form factors, inelastic kinematics (Lewin & Smith)
cosmology.py — Relic density, indirect detection, CMB constraints
idm_tools.py — science functions combining nuclear + cosmology
idm/ — the MCP tools (__init__.py) and HPC kernels (kernels.py)
meta/ — list_idm_skills / load_idm_skill (generic)
mcp_server/ — generic HEP-KE wrapper (server, cli, dispatch) + INSTRUCTIONS.md
skills/ — idm-tour, lz-event-inelastic-higgsino, hpc-dispatch-handoff
tests/
test_idm.py — physics benchmarks + tools, with assertions
test_dispatch_pack.py — HPC pack and kernels
test_benchmarks.py, test_cosmology.py — print-style benchmark scripts
test_contract.py, smoke_server.py — generic contract + live smoke test
```
## Skills
| skill | use it to |
|---|---|
| `idm-tour` | a guided first run through every tool for the 1.1 TeV / 350 keV benchmark |
| `lz-event-inelastic-higgsino` | test whether an inelastic WIMP explains the LZ 248 keV event: relic mass, δ window, plane scan, signatures, caveats |
| `hpc-dispatch-handoff` | run the scan / spectrum / modulation kernels on ALCF Polaris or NERSC Perlmutter |
## Install and run
```bash
git clone https://github.com/nesar/inelastic-dm-server.git && cd inelastic-dm-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 8008 # URL endpoint at http://127.0.0.1:8008/mcp
```
The server now runs on the standard MCP SDK v1 (`mcp>=1.27,<2`, FastMCP) from
`.venv`; the previous `.venv2` / `MCPServer` (SDK v2) setup is no longer used.
Scan and plot outputs go to `output/` under the directory the server runs
in (`run_server.sh` runs from the repo root).
## Connect a client
Claude Code (from the repo directory, `.mcp.json` is picked up automatically):
```bash
claude mcp add idm -- /path/to/inelastic-dm-server/run_server.sh
```
Hermes:
```bash
hermes config set mcp_servers.inelastic_dm.command "$HOME/github-integration/inelastic-dm-server/run_server.sh"
hermes config set mcp_servers.inelastic_dm.timeout 120
hermes mcp test inelastic_dm
```
Claude Desktop, Codex, ChatGPT, Antigravity and hep-genesis-agent: see
[the library site](https://hep-ke.github.io/hep-servers/#connect).
## Run on HPC
Everything is fast locally for the default grids; dispatch is for dense
scans and facility campaigns. Kernels are declared in `tools/idm/__init__.py`
(`DISPATCH_KERNELS`) and implemented in `tools/idm/kernels.py` (JSON in →
JSON out, numpy/scipy physics only):
| kernel | backs | dispatched server-side |
|---|---|---|
| `idm.kernels.scan_mass_splitting` | `scan_mass_splitting` | yes |
| `idm.kernels.recoil_spectrum` | `predict_recoil` | yes |
| `idm.kernels.annual_modulation` | `predict_annual_modulation` | yes |
| `idm.kernels.relic_density` | `compute_relic_density` | pack only |
| `idm.kernels.check_constraints` | `check_all_constraints` | pack only |
- **Client-side (hosted, recommended)**: `export_dispatch_pack` hands the
`tools/` package and the kernel manifest to the client's hep-genesis
harness, which stages and submits with its own credentials.
- **Server-side (your own machine)**: `auth_status`, then
`set_dispatch("perlmutter" | "polaris")`; the three tools above then run
their kernel as one facility job (the scan still writes
`output/scan_idm.npz` locally). Needs the hep-genesis backend in this
environment (`uv pip install -e <hep-genesis-agent>/backend[iri]`).
No SSH, no batch scripts, no credentials in the server. Details: the
`hpc-dispatch-handoff` skill.
## 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 yet)
uv run python tests/smoke_server.py # live stdio server: lists tools and prompts
python tests/test_benchmarks.py # print-style benchmark tables
```
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.
## Limitations
- A single LZ event: "consistent" means an expected count within a factor
of a few of one; the expected count is extremely steep in δ (at 1.1 TeV:
~745 events at 300 keV, 2 at 350 keV, 0 at 400 keV) and depends on the
Standard Halo Model parameters (v_0 = 220, v_esc = 544, v_E = 232 km/s).
- Relic density is semi-analytic freeze-out with a ~15% theory error;
`consistent_within_theory_err` uses that, `tension_sigma` uses Planck's 1%.
- `check_all_constraints`' verdict covers relic + Fermi-LAT + CMB; read the
LZ count from `direct_detection`.
- Indirect detection uses tabulated Fermi-LAT dSph limits (no J-factor
uncertainty); the CMB bound is a single p_ann limit.
- The scan and plot tools write to fixed names in `output/` (no output_dir
argument); a new scan overwrites the previous one.
## Citation and license
- Fan & Reece, "The LZ anomaly as inelastic dark matter", arXiv:2609.01504
- LZ Collaboration, "Search for new physics with an extended nuclear recoil ROI", arXiv:2609.02608
- LZ Collaboration, "Effective field theory and inelastic interpretations", arXiv:2609.02823
- Lewin & Smith, Astropart. Phys. 6 (1996) 87
- Kolb & Turner, *The Early Universe* (1990)
- Helm, Phys. Rev. 104 (1956) 1466
MIT license (see `LICENSE`).
TDQS
Scored across 14 tools
Physics tools each target a distinct computation (recoil spectrum, relic density, constraint check, parameter scan, modulation), and the dispatch quartet is clearly separated from physics. Minor overlap exists between check_all_constraints and scan_mass_splitting (single point vs. grid) and between predict_recoil and plot_recoil_spectrum, but descriptions and dependencies resolve these. list_idm_skills/load_idm_skill vs. describe_tools are close cousins in the discovery role but still distinguishable.
Nearly all names follow a clean verb_noun snake_case convention (predict_recoil, compute_relic_density, scan_mass_splitting, get_dispatch, set_dispatch). The only deviation is auth_status, a bare noun phrase, which breaks the verb-first pattern. get/set_dispatch pairs nicely and namespace prefixes (idm_) appear only on the skill tools, which is slightly uneven but readable.
14 tools sit comfortably in the well-scoped range, with 10 physics/compute tools covering the domain and 4 justified infrastructure tools for HPC dispatch state and kernel export. Each tool has a distinct job rather than being a thin wrapper variant.
The surface covers the core lifecycle: predict spectra, compute relic density, check and scan constraints, plot results, plus HPC offload and skill-based recipes. Minor gaps remain — no way to retrieve numeric constraint/likelihood values as structured data (only plots), and no explicit model/parameter listing or export of scan results beyond PNGs.