Skip to main content
Glama
sterile-nu-bbn-server

sterile-nu-bbn-server

by nesar
README.md
# sterile-nu-bbn-server

[![CI](https://github.com/nesar/sterile-nu-bbn-server/actions/workflows/ci.yml/badge.svg)](https://github.com/nesar/sterile-nu-bbn-server/actions/workflows/ci.yml)
`analysis` `trial` `particle-physics` `cosmology` `HPC`  ·  part of the [HEP-KE MCP server library](https://hep-ke.github.io/hep-servers/)

An MCP server that **bridges sterile neutrino particle physics with Big Bang
Nucleosynthesis cosmology**: from particle parameters (m_s, sin²2θ,
production mechanism) to ΔN_eff, relic density, light-element abundances,
the X-ray decay line and free streaming in a single call, checked against
observational data. Built as a companion to
[`bbn-server`](https://github.com/nesar/bbn-server), extending the
BBN framework into the BSM particle physics domain.

## At a glance

| | |
|---|---|
| Category | analysis, trial |
| Domain | particle physics, cosmology |
| HPC dispatch | yes (IRI + Globus via hep-genesis) |
| Skill prefix | `sterile_nu` (`list_sterile_nu_skills`, `load_sterile_nu_skill`) |
| Default port | `8007` (streamable-http) |
| Hosted endpoint | none |

## The science

Sterile neutrinos are hypothetical neutral fermions that mix with active
neutrinos. They appear in many extensions of the Standard Model and are
candidates for dark matter (keV-scale) or the source of short-baseline
oscillation anomalies (eV-scale). Their existence has direct, quantitative
consequences for:

| Scale | Observable | Data |
|---|---|---|
| **Particle** | Mixing angle sin²2θ, mass m_s | SBL experiments (BEST, STEREO), reactor anomalies |
| **Nuclear / BBN** | Primordial He-4 (Y_p), D/H, ⁷Li/H | Quasar absorption spectra, H II regions |
| **CMB** | N_eff (number of relativistic species) | Planck 2018, ACT, SPT; future CMB-S4 |
| **X-ray** | Decay line ν_s → ν_a + γ | NuSTAR, XMM-Newton, XRISM, Chandra |
| **LSS** | Free-streaming suppression | Lyman-α forest (SDSS, DESI) |

This server computes the **entire chain**: given (m_s, sin²2θ, production
mechanism), it predicts ΔN_eff, BBN abundances, X-ray line flux, and
free-streaming length — then checks all predictions against actual
observational data.

### Physics and validity

- **BBN**: Y_p, D/H, ⁷Li/H are fits to the full PRyMordial network over
  N_eff 2.04–6.04, ω_b ±15%, τ_n ±12 s (max deviation 0.11%, 0.26%, 0.14%).
  Exclusion is Δχ² vs the SM > 3.84 (95%, 1 dof): the SM itself carries
  χ² ≈ 2.8 from the D/H tension, which says nothing about sterile ν.
  BBN alone gives ΔN_eff < 0.55.
- **Mass regimes**: valid below ~100 keV (relativistic at BBN). At ≥ 1 MeV
  the particle decays during BBN and decay-product injection is **not
  modeled** — results there are flagged and are not constraints.
- **Known approximations**: eV partial thermalisation is a crude fit (a
  QKE run gives ΔN_eff = 0.93 at Δm² = 1 eV², sin²2θ = 1e-3 vs 0.40 here);
  Shi–Fuller ΔN_eff is a heuristic; X-ray fluxes are whole-halo.

### Questions to ask an agent

> "If the BEST experiment's sterile neutrino is real, what happens to
> primordial helium and deuterium?"

> "Can a 7 keV sterile neutrino be all the dark matter, and would
> XRISM see its X-ray decay line in the Perseus cluster?"

> "Scan the parameter space and show me where BBN, X-ray limits,
> and structure formation all agree."

## Tools

MCP tool names all carry a `sterile_nu` token so agents never confuse them
with a BBN abundance server's or a client harness's tools. Science tools
return a JSON string `{status, files, message, metadata}`.

| tool | what it does |
|---|---|
| `list_sterile_nu_skills` / `load_sterile_nu_skill` | server-side skills (also served as MCP prompts) |
| `describe_sterile_nu_tools` | Capabilities, physics, validity range, observational data — call first |
| `predict_sterile_nu` | **The bridge** for one point: ΔN_eff, Ω_s h², Y_p/D/H/Li7, BBN Δχ² vs SM, X-ray line, free streaming, regime flag |
| `predict_sterile_nu_grid` | Same for many points in one call (product or zip of mass/mixing lists) → compact table + CSV (HPC-dispatchable) |
| `check_sterile_nu_sbl_anomaly` | What BEST's best-fit sterile ν means for BBN and Planck N_eff |
| `predict_sterile_nu_xray_line` | X-ray line flux from DM decay; `target="all"` compares Perseus, M31, MW, Coma, stacks |
| `scan_sterile_nu_parameters` | Scan the (m_s, sin²2θ) plane → CSV/NPZ, BBN-allowed mixing per mass (HPC-dispatchable) |
| `plot_sterile_nu_exclusion` | Exclusion plane: BBN, overclosure, X-ray, Ly-α, 3.5 keV, invalid-regime hatching |
| `plot_sterile_nu_bbn_impact` | Y_p, D/H vs N_eff with observed bands and the BBN 95% ΔN_eff limit |
| `set_dispatch` / `get_dispatch` / `auth_status` / `export_dispatch_pack` | HPC dispatch (see [Run on HPC](#run-on-hpc)) |

Python functions behind them (`predict_from_particle_params`,
`scan_constraints`, `plot_exclusion`, `plot_bbn_vs_neff`, ... in
`tools/sterile_tools.py`; physics in `tools/physics.py`) keep their names
for notebooks and scripts (`notebooks/`, `run_predictions.py`). Figures use
a shared publication style (`tools/plotting.py`: STIX mathtext, no LaTeX
needed, colorblind-safe palette); every plot tool accepts `save_pdf`.

## Skills

| skill | use it to |
|---|---|
| `sterile-nu-tour` | a guided two-minute first run through every tool, with expected numbers |
| `sterile-nu-bbn-constraints` | constrain sterile neutrinos with BBN and N_eff: regimes, benchmark grids, exclusion plane, BEST anomaly |
| `kev-sterile-dm-xray` | keV sterile-neutrino dark matter: 3.5 keV line, X-ray limits, relic density, Lyman-α |
| `hpc-dispatch-handoff` | run the scan / grid kernels on ALCF Polaris or NERSC Perlmutter |

## Install and run

```bash
git clone https://github.com/nesar/sterile-nu-bbn-server.git && cd sterile-nu-bbn-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 8007   # URL endpoint at http://127.0.0.1:8007/mcp
```

`uv sync --extra notebook` adds Jupyter for the demo notebooks.

## Connect a client

Claude Code (from the repo directory, `.mcp.json` is picked up automatically):

```bash
claude mcp add sterile_nu -- /path/to/sterile-nu-bbn-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).

## Run on HPC

Every tool is analytic and fast locally (a 150 × 150 scan takes ~0.5 s);
dispatch is for facility campaigns, not speed. Two kernels are declared in
`tools/sterile_nu/__init__.py` (`DISPATCH_KERNELS`) and implemented in
`tools/sterile_nu/kernels.py` (numpy-only, JSON in → JSON out):

| kernel | backs | duration hint |
|---|---|---|
| `sterile_nu.kernels.scan_parameter_space` | `scan_sterile_nu_parameters` | 600 s |
| `sterile_nu.kernels.predict_points` | `predict_sterile_nu_grid` | 300 s |

- **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 two tools above then run
  their kernel as one facility job and still write their CSV/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
```

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. Server-specific code: `tools/physics.py`,
`tools/sterile_tools.py`, `tools/plotting.py`, `tools/sterile_nu/`,
`mcp_server/INSTRUCTIONS.md`, `skills/`, `tests/test_physics.py`,
`tests/test_dispatch_pack.py`.

## Limitations

- BBN abundances are a fit to PRyMordial, not a network run; for
  full-network abundances at other (N_eff, ω_b, τ_n) use a BBN abundance
  server.
- The only BBN effect modeled is ΔN_eff: for m_s ≥ ~1 MeV decay injection
  (photodissociation, hadronic injection, entropy release) is not modeled,
  so results there are flagged and are not constraints.
- eV partial thermalisation is a crude fit (limits there are conservative);
  the 10 eV seam between the eV fit and the DW relic density gives a ~30×
  jump in the BBN limit; Shi–Fuller ΔN_eff is a heuristic (0.1 × DW).
- X-ray fluxes are whole-halo with f_DM = 1 (no field of view, no profile
  integration); X-ray limits are tabulated points checked within 30% in mass.

## Citation and license

Physics references:

- Dodelson & Widrow, PRL 72, 17 (1994) — non-resonant production
- Shi & Fuller, PRL 82, 2832 (1999) — resonant production
- Pal & Wolfenstein, PRD 25, 766 (1982) — radiative decay rate
- Burns, Tait & Valli, EPJC 84, 86 (2024) — PRyMordial (BBN calibration)
- Pitrou, Coc, Uzan & Vangioni, PhysRep 754, 1 (2018) — BBN review
- Roach+ (2020), PRD 101, 103011 — NuSTAR X-ray limits
- Dessert+ (2020), Science 367, 1465 — XMM-Newton blank-sky limits
- Barinov+ (2022), PRL 128, 232501 — BEST experiment
- Aver, Olive & Skillman, JCAP 07 (2021) 029 — primordial He-4
- Cooke, Pettini & Steidel, ApJ 855 (2018) 102 — primordial D/H

MIT license (see `LICENSE`).

TDQS

A3.7/5.0

Scored across 14 tools

Disambiguation4/5

The core physics tools are clearly separated by intent: predict_sterile_nu (one point), predict_sterile_nu_grid (many points, inline table), scan_sterile_nu_parameters (file-producing plane scan), and predict_sterile_nu_xray_line (X-ray only), and the descriptions explicitly steer users between them. Residual overlap exists between the grid predictor and the parameter scan (both compute BBN/overclosure over many points) and check_sterile_nu_sbl_anomaly is essentially a canned predict call, but the file-vs-table and benchmark-vs-generic distinctions keep misselection unlikely.

Naming Consistency4/5

The physics tools follow a strong verb_noun pattern with a consistent sterile_nu namespace (list_/load_/describe_/predict_/scan_/plot_/check_sterile_nu_*), which makes the domain surface very readable. The four dispatch tools (auth_status, export_dispatch_pack, get_dispatch, set_dispatch) drop the namespace infix and auth_status is noun-phrased rather than verb-first, a minor but visible deviation from the otherwise uniform convention.

Tool Count4/5

At 14 tools the server sits comfortably in the well-scoped range, with roughly five prediction/scan tools, two plotting tools, three skill-framework tools, and four dispatch tools. A few entries are conveniences rather than necessities (check_sterile_nu_sbl_anomaly duplicates a fixed predict call; the list/load/describe skill trio is somewhat ceremonial), but nothing feels like padding at this scale.

Completeness4/5

The surface covers the sterile-neutrino workflow end to end: single-point and batch prediction, X-ray line limits, parameter-plane scanning, exclusion and BBN-impact plots, plus regime validity flagging and remote dispatch for heavy runs. Gaps are modest — there is no way to query the underlying observational limit tables directly, no separate tool for non-thermal/resonant production scenarios, and no combined-fit or data-comparison helper — but agents can work around these via the existing predict and describe tools.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues