Skip to main content
Glama
bbn-mcp-server

bbn-mcp-server

by nesar

bbn-server

CI analysis trial cosmology nuclear-physics HPC · part of the HEP-KE MCP server library

An MCP server that exposes science tools — Big Bang Nucleosynthesis, the particle physics of the universe's first three minutes — to any LLM agent: light-element abundances as a function of the baryon density, extra relativistic species and the neutron lifetime, the BBN/CMB concordance fit, and joint Ω_b h² × ΔN_eff constraints whose PRyMordial grids can run on DOE HPC facilities. Built on the same pattern as power-spectrum-server and gaia-data-server; the multi-agent client in multiagent-client-demo drives any of these servers unchanged.

At a glance

Category

analysis, trial

Domain

cosmology, nuclear physics

HPC dispatch

yes (IRI + Globus via hep-genesis)

Skill prefix

bbn (list_bbn_skills, load_bbn_skill)

Default port

8006 (streamable-http)

Hosted endpoint

none

Related MCP server: lattice-mcp-server

The science

Between one second and a few minutes after the Big Bang, the expanding universe ran a nuclear reactor. Its output — the primordial abundances of helium-4, deuterium, helium-3 and lithium-7 — is still measurable today, and it depends on exactly three things an agent can turn:

  • the baryon density Ω_b h² (how much ordinary matter exists),

  • extra relativistic species ΔN_eff (any light particle beyond the three Standard Model neutrinos — dark radiation, sterile states, axions — speeds up the expansion and changes the yields),

  • the neutron lifetime τ_n (which sets the neutron/proton ratio at weak freeze-out — and whose laboratory measurements currently disagree by ~10 s, the "bottle vs beam" puzzle).

Primordial abundances vs baryon density

The classic stories are all here: the abundances and the CMB agree on the baryon density of the universe (concordance), helium counts the light degrees of freedom at t ~ 1 s, and the lithium-7 panel shows a famous unsolved problem — the prediction is ~3× the observed Spite plateau.

Helium and deuterium vs the neutron lifetime

All computations run on PRyMordial (Burns, Tait & Valli, EPJC 84 (2024) 86), the community Python code for precision BBN within and beyond the Standard Model. PRyMordial is GPL-3.0 and not on PyPI, so it is not vendored here — a setup script fetches a pinned copy into extern/ (gitignored).

Predictions carry the nuclear-rate systematic (PRIMAT compilation, PRyMordial's default) in quadrature with the measurement errors — the d(p,γ)³He rate alone moves D/H by a few percent, which is a genuine, live discussion in the field, not a bug.

Questions to ask an agent:

"Does the baryon density measured by Planck in the CMB correctly predict the deuterium abundance we observe in quasar spectra? Scan the baryon density, fit it from the abundances, and give me the verdict in sigma."

"If there were one extra neutrino species in the early universe, what would have happened to primordial helium, and is that allowed by the data?"

The first one becomes a genuine two-server question when this server is hosted next to a CMB-capable one (compute the damping tail there, the deuterium here).

Tools

tool

what it does

list_bbn_skills / load_bbn_skill

server-side skills (also served as MCP prompts)

describe_bbn_inputs()

parameters, measured abundances, references, the classic questions — call it first

compute_bbn_abundances(omega_b_h2, delta_neff, tau_n_s)

one full 63-reaction run: N_eff, Yp, D/H, ³He/H, ⁷Li/H, each with its pull (σ) against observation

scan_bbn_parameter(output_dir, parameter, ...)

vary one input — omega_b_h2 (the Schramm-plot calculation), delta_neff (each point re-solves the thermal history), or tau_n_s — with the other two held fixed → CSV (unique name per scan, so scans at different fixed values coexist). HPC-dispatchable

plot_bbn_scan(scan_files, output_dir, ...)

publication figure from one or several scans of the same parameter: Yp, D/H, ³He/H, ⁷Li/H panels with measured bands, plus the Planck Ω_b h² band, the SM N_eff line, or the bottle/beam τ_n bands as appropriate; optional PDF

fit_bbn_baryon_density(scan_file, observables)

χ² fit on an Ω_b h² scan: the BBN-preferred Ω_b h² ± 1σ, compared with Planck — the concordance test in one number

scan_bbn_grid(output_dir, ...)

Ω_b h² × ΔN_eff grid of PRyMordial runs → CSV with χ² (D/H, Yp, optional Planck Ω_b h² prior), best fit and 68% profile intervals on ΔN_eff and Ω_b h². Heavy; HPC-dispatchable

plot_bbn_grid(grid_file, output_dir, save_pdf=False)

68% / 95% contours in the Ω_b h² – ΔN_eff plane with the Planck band and the SM line

set_dispatch / get_dispatch / auth_status / export_dispatch_pack

HPC dispatch (see Run on HPC)

ΔN_eff is an input here. The ΔN_eff a specific particle model produces (e.g. a sterile neutrino of given mass and mixing) comes from that model's own server; feed the value into these tools. Figures use matplotlib's built-in mathtext (STIX fonts) — no LaTeX installation is needed.

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

bbn-tour

a guided first run through every tool, with the numbers to expect

bbn-cmb-concordance

fit Ω_b h² from D/H (and Yp), compare with Planck, Schramm plot, lithium problem

bbn-neff-dark-radiation

constrain ΔN_eff: 1D scan, joint Ω_b h² × ΔN_eff grid with/without the CMB prior, contours

hpc-dispatch-handoff

run the PRyMordial grid / point kernels on Polaris or Perlmutter

Install and run

git clone https://github.com/nesar/bbn-server.git && cd bbn-server
uv sync                                         # creates this server's own .venv from uv.lock
uv run python scripts/setup_prymordial.py       # fetches PRyMordial + precomputes tables (~1 min, once)
./run_server.sh                                 # stdio (what agent clients launch)
./run_server.sh --transport streamable-http --port 8006   # URL endpoint at http://127.0.0.1:8006/mcp

PRyMordial. It is GPL-3.0, not on PyPI and has no setup.py, so it is neither a dependency in pyproject.toml nor vendored. The setup script clones the pinned commit 725d8a8 into extern/PRyMordial (override with the PRYM_DIR env var) and runs one Standard Model computation with the save flags on, so the thermal background and weak rates are cached — that makes parameter scans ~6× faster and lets the server run without write access to the checkout. Its Python dependencies (numpy, scipy, numba, numdifftools) are locked in uv.lock. On an HPC node the kernels fetch the same commit themselves (see Run on HPC).

The default port is now 8006 (from [tool.mcp-server].port; it was 8003 in the tutorial version — pass --port 8003 if a deployment relies on it). 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 the setup script and ./run_server.sh as above.

Connect a client

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

claude mcp add bbn -- /path/to/bbn-server/run_server.sh

Claude Desktop, Codex, ChatGPT, Antigravity and hep-genesis-agent: see the library site and docs/mcp-clients.md.

Run on HPC

Each PRyMordial run takes ~1 s with cached tables, but every ΔN_eff ≠ 0 point re-solves the thermal history (~4-10 s per core), so a fine Ω_b h² × ΔN_eff grid is tens of minutes to hours serial. Two kernels in tools/bbn/kernels.py (declared in DISPATCH_KERNELS, tools/bbn/__init__.py) carry that work:

kernel

used by

duration hint

bbn.kernels.bbn_abundance_points

scan_bbn_parameter, scan_bbn_grid

1800 s

bbn.kernels.bbn_abundance_grid

client-side grids

3600 s

Both run every point independently on all cores of one node (n_workers=0), and the tools call the same functions locally, so results are identical. On the node the kernel downloads PRyMordial at the pinned commit into the job directory (GitHub tarball, stdlib only; set PRYM_DIR to a staged checkout on a node without outbound internet) — GPL code is never shipped in the dispatch pack. pip_deps: numpy, scipy, numba, numdifftools (mcp_server.dispatch adds pydantic for the pack's imports).

  • Client-side (hosted, recommended): export_dispatch_pack hands the kernels to the client's hep-genesis harness, which stages and submits them with its own IRI / Globus credentials.

  • Server-side (your own machine): auth_status, then set_dispatch("polaris" | "perlmutter"); scan_bbn_grid and scan_bbn_parameter then run as facility jobs and report computed_on. Needs the hep-genesis backend in this .venv (uv pip install -e <hep-genesis-agent>/backend[iri]).

The hpc-dispatch-handoff skill has the step-by-step recipe.

Development and tests

uv sync --extra dev
uv run python scripts/setup_prymordial.py      # science tests skip without it
uv run ruff check .
uv run pytest -m "not network and not slow"   # contract + science tests (what CI runs)
uv run pytest -m "network or slow"            # kernel fetching PRyMordial like a compute node; larger grid
uv run python tests/smoke_server.py            # live stdio server: lists tools and prompts

CI has no PRyMordial checkout, so it runs the contract tests and the PRyMordial-free science tests; the PRyMordial tests (SM abundances, scans, concordance fit, kernels, grid) run wherever the setup script has been run. The weekly network job exercises the compute-node fetch path.

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/bbn/.

Limitations

  • PRyMordial's default PRIMAT nuclear rates; scans and grids use the 12-reaction network (abundances within ~0.2% of the 63-reaction one used by compute_bbn_abundances).

  • ΔN_eff enters as extra radiation only (no change to the neutrino decoupling physics or electron-neutrino asymmetry).

  • scan_bbn_grid intervals are profile-likelihood Δχ² ≤ 1 from spline-interpolated abundances inside the grid — good to a few % of σ for smooth grids, not a substitute for an MCMC.

  • No lithium depletion modelling: the ⁷Li pull is the lithium problem, as observed.

Citation and license

  • PRyMordial: A.-K. Burns, T. M. P. Tait, M. Valli, EPJC 84 (2024) 86, arXiv:2307.07061 (GPL-3.0, fetched, not vendored).

  • Yp: Aver et al., JCAP 03 (2021) 027. D/H: Cooke, Pettini & Steidel, ApJ 855 (2018) 102. Li7/H: Sbordone et al., A&A 522 (2010) A26.

  • Planck 2018, A&A 641 (2020) A6. Neutron lifetime: PDG 2024; UCNτ, PRL 127 (2021) 162501; Yue et al., PRL 111 (2013) 222501.

Code in this repository: MIT, see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables LLM agents to compute and analyze the thermodynamics of hot, strongly interacting matter from lattice QCD, including the equation of state, hadron resonance gas properties, and associated plots, using the latqcdtools package.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Exposes HACC cosmological hydrodynamic simulation emulators (GSMF, HMF, cluster profiles, P(k) suppression) as MCP tools, allowing LLM agents to predict observables and generate comparison plots.
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Exposes the public LSST DESC cosmology stack as agent tools for theory predictions, data vectors, likelihoods, Fisher forecasts, measurement pipelines, covariances, pseudo-C_ell measurements, and data-vector concealment, with multi-tool skills and optional HPC dispatch.
      58
      MIT