Labsco
MCP SERVER

Root CLI and MCP

by mohamedelashri

Ask about a CERN ROOT file and get the answer, not a script: branches listed, cuts applied, histograms computed and fitted, invariant mass calculated, plots written to disk.

Physical Sciences & Scientific ComputingVerified
Summary
Answers the physics question instead of writing a script that answers it.

Asking for the muon pT distribution gets a computed histogram and a saved plot, which removes the write-run-debug loop that normally sits between the question and the answer. Choose the mode deliberately: core keeps the dependency set small for inspection and export, and extended is the one that brings fitting, kinematics and plotting — and it can be switched at runtime rather than at install. Before any shared deployment, set allowed_roots, because the default is deliberately permissive for local use.

What it is

An analysis layer over ROOT files. It inspects trees and branches, reads data with physics selections applied, and computes and plots the distributions — with the heavier physics tools switched on by mode rather than always loaded.

What you get
  • Files browsed in a configured resource, a file's structure inspected, its integrity validated, and the branches of a TTree or RNTuple listed by pattern
  • Branch data read over an entry range with a selection applied, and per-branch statistics that accept derived variables through defines
  • Data exported to JSON, CSV or Parquet, with compression, straight from a selection
  • 1D and 2D histograms computed with bins, range and weights, and derived variables available in the 2D case
  • Histogram fitting with a model, initial guesses, bounds and fixed parameters
  • Invariant mass from pt, eta and phi branches, and correlation between two branches by Pearson or Spearman
  • 1D and 2D plots written to a path, either from a histogram you already computed or straight from the file
  • Bin-by-bin arithmetic between two histograms — asymmetry, difference, ratio
  • A mode switch at runtime between core and extended, and a call that reports which mode and capabilities are active
Requirements

Pip install root-mcp, then root-mcp --data-path /path/to/your/data, or set ROOT_MCP_DATA_PATH once. The mode decides both the tools and the dependencies: core needs uproot, awkward, numpy and pandas and covers inspection, reading, statistics and export; extended adds scipy and matplotlib and brings in histograms, fitting, kinematics, correlations and plotting. Remote XRootD access needs the xrootd extra plus --allow-remote and a named resource. Native PyROOT execution is opt-in behind --enable-root with --allowed-root limiting where it may run. The permissive default, an empty allowed_roots, means any local path is reachable — it is meant for a trusted local session, and the HTTP transport refuses to start without authentication, Origin validation and a restrictive policy. The same backend also ships as a CLI. MIT.

Setup effort

One command — pip install root-mcp