compute_correlation
Compute correlation between branches
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.
LABSCO SUMMARY
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.
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.
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.
One command — pip install root-mcp
USE CASES
Inspect its structure, list the branches of the tree that matter, and validate the file before spending time on it.
Compute the histogram over the branch with your bins, range and selection, then write the plot to a file to look at.
Fit the histogram with a model, supplying initial guesses, bounds or fixed parameters where the fit needs help.
Compute invariant mass from the pt, eta and phi branches, then histogram and fit the result.
Compute a histogram for each and take the ratio, difference or asymmetry bin by bin, then plot what comes out.
Read the branches you need with the selection applied and export them as JSON, CSV or Parquet.
Run in core mode for inspection and export, and switch to extended at runtime when the work turns into fitting and plotting.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
compute_correlationCompute correlation between branches
compute_histogramCompute 1D histogram with fitting support
compute_histogram_2dCompute 2D histogram (supports derived variables via defines)
compute_invariant_massCompute invariant mass from 4-vectors
export_dataExport branch data to JSON, CSV, or Parquet
fit_histogramFit histogram with model function
get_branch_statsGet statistics for branches (supports derived variables via defines)
get_server_infoGet server mode and capabilities
histogram_arithmeticPerform bin-by-bin arithmetic on two histograms (e.g. asymmetry, difference, ratio)
inspect_fileInspect ROOT file structure and contents
list_branchesList branches in a TTree or RNTuple
list_filesList ROOT files in a resource
plot_histogram_1dCreate and save a 1D histogram plot. Provide EITHER 'data' (pre-calculated) OR 'path', 'tree_name', 'branch', 'bins' (compute from file).
plot_histogram_2dCreate and save a 2D histogram plot. Provide EITHER 'data' (pre-calculated) OR 'path', 'tree_name', 'branch_x'...' (compute from file).
read_branchesRead branch data from a TTree or RNTuple
switch_modeSwitch between core and extended modes
validate_fileValidate ROOT file integrity
BEFORE YOU INSTALL
17 tools when we connected.
The documented client runs the server on your machine.
CONTEXT COST
Rated by the size of the 17 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
pip install root-mcp{
"mcpServers": {
"root-mcp": {
"command": "root-mcp",
"args": [
"--data-path",
"<YOUR_PATH_TO_DATA>"
]
}
}
}