Tool Reference
Tool Reference
Complete reference for all ROOT-MCP tools, organized by mode availability.
Tool Organization
ROOT-MCP provides 17 standard tools plus 3 optional native ROOT tools organized into three categories:
Core Tools (9): Always available in both core and extended modes
Extended Tools (8): Only available in extended mode
Native ROOT Tools (3): Only available when a ROOT installation is present and
features.enable_root: trueis set
All tools return a standard JSON response structure:
{
"data": { ... }, // Primary result
"metadata": { ... }, // Operation details, execution time
"suggestions": [ ... ] // Optional next steps or hints
}
Mode Information
Check current mode and available tools:
{
"tool": "get_server_info",
"arguments": {}
}
Switch modes at runtime:
{
"tool": "switch_mode",
"arguments": {"mode": "extended"}
}
Core Tools
Core tools are always available in both core and extended modes. They provide file operations, data reading, and basic statistics.
File Discovery
list_files
List accessible ROOT files under a configured resource.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
Default |
|---|---|---|---|---|
|
|
No |
Resource ID from config |
First resource |
|
|
No |
Glob pattern (e.g., |
|
|
|
No |
Maximum files to return |
|
Example:
{
"tool": "list_files",
"arguments": {
"pattern": "*.root",
"limit": 10
}
}
Response:
{
"data": {
"files": [
{
"path": "/data/sample.root",
"size_bytes": 1306965,
"size_human": "1.2 MB",
"modified": "2024-05-14T10:45:17",
"resource": "local_data"
}
],
"total_matched": 1,
"total_scanned": 1
}
}
inspect_file
Inspect ROOT file structure including trees, histograms, and directories.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Absolute path to ROOT file |
|
|
No |
Include histogram metadata |
|
|
No |
Include TTree metadata |
Example:
{
"tool": "inspect_file",
"arguments": {
"path": "/data/sample.root"
}
}
Response:
{
"data": {
"path": "/data/sample.root",
"size_bytes": 1306965,
"trees": [
{
"name": "events",
"entries": 10000,
"branches": 26,
"total_bytes": 1200000
}
],
"histograms": [],
"directories": []
}
}
list_branches
List branches in a TTree or RNTuple with type information.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Absolute path to ROOT file |
|
|
Yes |
TTree name (e.g., |
|
|
No |
Glob pattern (e.g., |
|
|
No |
Maximum branches to return |
|
|
No |
Compute statistics (slower) |
Example:
{
"tool": "list_branches",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"pattern": "muon_*"
}
}
Response:
{
"data": {
"tree_name": "events",
"total_entries": 10000,
"branches": [
{
"name": "muon_pt",
"type": "float32",
"is_jagged": true,
"interpretation": "var * float32"
},
{
"name": "muon_eta",
"type": "float32",
"is_jagged": true
}
]
}
}
validate_file
Check ROOT file integrity and readability.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Absolute path to ROOT file |
Example:
{
"tool": "validate_file",
"arguments": {
"path": "/data/sample.root"
}
}
Response:
{
"data": {
"valid": true,
"readable": true,
"warnings": [],
"metadata": {
"num_objects": 5,
"num_trees": 1,
"trees": ["events"],
"compression_ratio": 2.3
}
}
}
Data Access
read_branches
Read branch data from TTree with optional filtering and derived branches.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Absolute path to ROOT file |
|
|
Yes |
TTree name |
|
|
Yes |
Branch names (physical or derived) |
|
|
No |
Cut expression (e.g., |
|
|
No |
Maximum entries to return |
|
|
No |
Number of entries to skip |
|
|
No |
Start entry (alternative to offset) |
|
|
No |
Stop entry (alternative to limit) |
|
|
No |
Flatten jagged arrays |
|
|
No |
Derived variables |
Example (Basic):
{
"tool": "read_branches",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branches": ["muon_pt", "muon_eta"],
"selection": "muon_pt > 20",
"limit": 100
}
}
Example (Derived Branches):
{
"tool": "read_branches",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branches": ["met", "met_x", "met_y"],
"defines": {
"met_x": "met * cos(met_phi)",
"met_y": "met * sin(met_phi)"
},
"selection": "met > 50"
}
}
Response:
{
"data": {
"branches": ["muon_pt", "muon_eta"],
"entries": 100,
"is_jagged": true,
"records": [
{"muon_pt": [25.3, 30.1], "muon_eta": [1.2, -0.5]},
{"muon_pt": [45.7], "muon_eta": [0.8]}
]
},
"metadata": {
"entries_selected": 100,
"selection": "muon_pt > 20"
}
}
get_branch_stats
Compute basic statistics for branches.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Absolute path to ROOT file |
|
|
Yes |
TTree name |
|
|
Yes |
Branch names |
|
|
No |
Optional cut expression |
|
|
No |
Derived variables |
Example:
{
"tool": "get_branch_stats",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branches": ["met", "muon_pt"]
}
}
Response:
{
"data": {
"met": {
"count": 10000,
"mean": 45.2,
"std": 28.3,
"min": 0.0,
"max": 250.5,
"median": 38.7,
"percentiles": {
"25": 25.1,
"75": 60.3
}
},
"muon_pt": {
"count": 15234,
"mean": 35.6,
"std": 22.1,
"min": 10.0,
"max": 180.2
}
}
}
Data Export
export_data
Export branch data to JSON, CSV, or Parquet format.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Input ROOT file path |
|
|
Yes |
TTree name |
|
|
Yes |
Branches to export |
|
|
Yes |
Output file path |
|
|
Yes |
|
|
|
No |
Optional cut expression |
|
|
No |
Maximum entries to export |
|
|
No |
Compress output (gzip) |
Example:
{
"tool": "export_data",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branches": ["run", "event", "met"],
"output_path": "/exports/data.parquet",
"format": "parquet",
"selection": "met > 50"
}
}
Response:
{
"data": {
"output_path": "/exports/data.parquet",
"format": "parquet",
"entries_exported": 1823,
"file_size_bytes": 45678,
"compressed": false
}
}
Server Management
switch_mode
Switch between core and extended modes at runtime.
Mode: Core (always available)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
|
Example:
{
"tool": "switch_mode",
"arguments": {
"mode": "extended"
}
}
Response:
{
"status": "success",
"previous_mode": "core",
"current_mode": "extended",
"message": "Switched from core to extended mode",
"extended_features_available": true
}
get_server_info
Get server information including current mode and capabilities.
Mode: Core (always available)
Arguments: None
Example:
{
"tool": "get_server_info",
"arguments": {}
}
Response:
{
"server_name": "root-mcp",
"version": "5",
"current_mode": "extended",
"extended_components_loaded": true,
"available_modes": ["core", "extended"],
"root_native_available": true,
"root_native_enabled": true,
"root_version": "6.32/02",
"root_features": {"rdataframe": true, "roofit": true, "tmva": false},
"capabilities": {
"core_tools": 9,
"extended_tools": 8,
"root_native_tools": 3,
"total_tools": 20
}
}
Extended Tools
Extended tools are only available in extended mode. They require scipy and matplotlib and provide advanced analysis capabilities.
If you try to use an extended tool in core mode, you’ll receive an error:
{
"error": "mode_error",
"message": "Tool 'fit_histogram' requires extended mode. Current mode: core",
"hint": "Use switch_mode tool to enable extended mode"
}
Histogram Analysis
compute_histogram
Create 1D histogram with optional fitting support.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
ROOT file path(s) |
|
|
Yes |
TTree name |
|
|
Yes |
Branch to histogram |
|
|
Yes |
Number of bins |
|
|
No |
Range (auto if omitted) |
|
|
No |
Cut expression |
|
|
No |
Weight branch name |
|
|
No |
Derived variables |
|
|
No |
Model (see fit_histogram) |
|
|
No |
Fit range |
Example:
{
"tool": "compute_histogram",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branch": "dimuon_mass",
"bins": 100,
"range": [2.8, 3.4],
"fit_model": "gaussian",
"fit_range": [3.0, 3.2]
}
}
Response:
{
"data": {
"bin_edges": [2.8, 2.806, ..., 3.4],
"bin_counts": [45, 52, ..., 38],
"bin_errors": [6.7, 7.2, ..., 6.2],
"mean": 3.096,
"std": 0.093,
"fit": {
"model": "gaussian",
"parameters": {
"amplitude": 1250.5,
"mean": 3.0969,
"sigma": 0.0432
},
"errors": {
"amplitude": 15.2,
"mean": 0.0003,
"sigma": 0.0004
},
"chi2": 45.3,
"ndof": 47,
"chi2_ndof": 0.96
}
}
}
compute_histogram_2d
Create 2D histogram for correlation studies.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
ROOT file path(s) |
|
|
Yes |
TTree name |
|
|
Yes |
X-axis branch |
|
|
Yes |
Y-axis branch |
|
|
Yes |
Number of bins in X |
|
|
Yes |
Number of bins in Y |
|
|
No |
X range |
|
|
No |
Y range |
|
|
No |
Cut expression |
|
|
No |
Derived variables |
Example:
{
"tool": "compute_histogram_2d",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"x_branch": "muon_eta",
"y_branch": "muon_phi",
"x_bins": 50,
"y_bins": 50,
"x_range": [-2.5, 2.5],
"y_range": [-3.14, 3.14]
}
}
Response:
{
"data": {
"bin_edges_x": [-2.5, -2.4, ..., 2.5],
"bin_edges_y": [-3.14, -3.01, ..., 3.14],
"bin_counts": [[12, 15, ...], [18, 20, ...], ...],
"total_entries": 10000
}
}
histogram_arithmetic
Perform bin-by-bin arithmetic on two histograms.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
|
|
|
Yes |
First histogram data object |
|
|
Yes |
Second histogram data object |
Example:
{
"tool": "histogram_arithmetic",
"arguments": {
"operation": "asymmetry",
"data1": { ... },
"data2": { ... }
}
}
Response:
{
"data": {
"bin_counts": [...],
"bin_errors": [...],
"entries": 500
}
}
fit_histogram
Fit mathematical model to existing histogram data.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Histogram bin centers |
|
|
Yes |
Histogram bin counts |
|
|
Yes |
Model name (see below) |
|
|
No |
Initial parameter guesses |
|
|
No |
Fixed parameters |
|
|
No |
Parameter bounds |
Available Models:
gaussian: Normal distributionexponential: Exponential decaypolynomial: Polynomial (auto-detected degree from guess or explicitpolynomial_N)crystal_ball: Crystal Ball function (for resonances)gaussian_2d: 2D Gaussian (for 2D histograms)polynomial_2d: 2D polynomialCustom: Raw string formula (e.g.
"a*x**2 + b"- params auto-detected)
Example:
{
"tool": "fit_histogram",
"arguments": {
"bin_centers": [3.0, 3.01, 3.02, ...],
"bin_counts": [45, 52, 58, ...],
"model": "gaussian",
"initial_params": {
"mean": 3.1,
"sigma": 0.05
}
}
}
Response:
{
"data": {
"model": "gaussian",
"parameters": {
"amplitude": 1250.5,
"mean": 3.0969,
"sigma": 0.0432
},
"errors": {
"amplitude": 15.2,
"mean": 0.0003,
"sigma": 0.0004
},
"chi2": 45.3,
"ndof": 47,
"chi2_ndof": 0.96,
"success": true
}
}
Kinematics
compute_invariant_mass
Calculate invariant mass from particle 4-vectors.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
ROOT file path |
|
|
Yes |
TTree name |
|
|
Yes |
Transverse momentum branches |
|
|
Yes |
Pseudorapidity branches |
|
|
Yes |
Azimuthal angle branches |
|
|
No |
Particle mass branches |
|
|
No |
Cut expression |
|
|
No |
Maximum entries |
Example:
{
"tool": "compute_invariant_mass",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"pt_branches": ["muon1_pt", "muon2_pt"],
"eta_branches": ["muon1_eta", "muon2_eta"],
"phi_branches": ["muon1_phi", "muon2_phi"],
"mass_branches": ["muon1_mass", "muon2_mass"],
"selection": "muon1_pt > 20 && muon2_pt > 20"
}
}
Response:
{
"data": {
"invariant_mass": [91.2, 89.5, 92.1, ...],
"entries": 5432
},
"metadata": {
"entries_processed": 5432
}
}
Statistical Analysis
compute_correlation
Compute statistical correlations between branches.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
ROOT file path |
|
|
Yes |
TTree name |
|
|
Yes |
Branches to correlate |
|
|
No |
|
|
|
No |
Cut expression |
Example:
{
"tool": "compute_correlation",
"arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branches": ["met", "jet1_pt", "jet2_pt"],
"method": "pearson"
}
}
Response:
{
"data": {
"correlation_matrix": [
[1.0, 0.45, 0.38],
[0.45, 1.0, 0.62],
[0.38, 0.62, 1.0]
],
"branches": ["met", "jet1_pt", "jet2_pt"],
"method": "pearson",
"p_values": [
[0.0, 0.001, 0.002],
[0.001, 0.0, 0.0],
[0.002, 0.0, 0.0]
]
}
}
Visualization
plot_histogram_1d
Generate a 1D histogram plot.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Output file path (e.g. “/tmp/plot.png”) |
|
|
No |
Pre-calculated histogram data |
|
|
No |
ROOT file path (if data omitted) |
|
|
No |
TTree name (if data omitted) |
|
|
No |
Branch name (if data omitted) |
|
|
No |
Number of bins |
|
|
No |
Range |
|
|
No |
Cut expression |
|
|
No |
Weight branch name |
|
|
No |
Derived variables |
|
|
No |
Plot title |
|
|
No |
X-axis label |
|
|
No |
Y-axis label |
|
|
No |
Log scale Y axis |
|
|
No |
Plot style (“default”, “publication”, “presentation”) |
Example (From Data):
{
"tool": "plot_histogram_1d",
"arguments": {
"data": { ... },
"output_path": "/tmp/mass_plot.png",
"title": "Mass Distribution"
}
}
plot_histogram_2d
Generate a 2D histogram plot.
Mode: Extended only
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Output file path |
|
|
No |
Pre-calculated 2D data |
|
|
No |
ROOT file path (if data omitted) |
|
|
No |
TTree name (if data omitted) |
|
|
No |
X Branch |
|
|
No |
Y Branch |
|
|
No |
X bins |
|
|
No |
Y bins |
|
|
No |
X Range |
|
|
No |
Y Range |
|
|
No |
Cut expression |
|
|
No |
Derived variables |
|
|
No |
Matplotlib colormap (e.g. “viridis”) |
|
|
No |
Log scale color |
|
|
No |
Plot style |
Example (From Data):
{
"tool": "plot_histogram_2d",
"arguments": {
"data": { ... },
"output_path": "/tmp/correlation.png",
"colormap": "inferno"
}
}
Response:
{
"data": {
"plot_path": "/tmp/correlation.png",
"format": "png",
"statistics": { ... }
}
}
Native ROOT Tools
Native ROOT tools are only available when a ROOT/PyROOT installation is detected and features.enable_root: true is set in your config. They run code in a sandboxed subprocess and return structured results.
All code is validated by an AST-based sandbox before execution. Dangerous imports (os, sys, subprocess, socket) and builtins (exec, eval, __import__) are blocked.
Use get_server_info to confirm availability:
{"root_native_available": true, "root_native_enabled": true}
Code Execution
run_root_code
Execute arbitrary PyROOT/Python code in a sandboxed subprocess.
Mode: Extended + ROOT (enable_root: true)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
PyROOT/Python code to execute |
|
|
No |
Execution timeout in seconds (default: config value) |
|
|
No |
Working directory for the subprocess |
Example:
{
"tool": "run_root_code",
"arguments": {
"code": "import ROOT\nf = ROOT.TFile.Open('/data/sample.root')\nt = f.Get('events')\nprint(t.GetEntries())"
}
}
Response:
{
"data": {
"stdout": "10000\n",
"stderr": "",
"return_code": 0,
"execution_time_s": 1.2
}
}
run_rdataframe
Compute histograms using ROOT’s RDataFrame without writing boilerplate.
Mode: Extended + ROOT (enable_root: true)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Absolute path to ROOT file |
|
|
Yes |
TTree name |
|
|
Yes |
Branch to histogram |
|
|
Yes |
Number of bins |
|
|
Yes |
Histogram range |
|
|
No |
Filter expression passed to |
|
|
No |
Derived columns |
Example:
{
"tool": "run_rdataframe",
"arguments": {
"path": "/data/drell_yan.root",
"tree_name": "events",
"branch": "dimuon_mass",
"bins": 100,
"range": [70, 110],
"selection": "mu1_pt > 20 && mu2_pt > 20"
}
}
Response:
{
"data": {
"bin_edges": [70.0, 70.4, ..., 110.0],
"bin_counts": [12, 18, ..., 9],
"bin_errors": [3.5, 4.2, ..., 3.0],
"entries": 8234,
"mean": 91.2,
"std": 3.1
}
}
run_root_macro
Execute a C++ ROOT macro via gROOT.ProcessLine.
Mode: Extended + ROOT (enable_root: true)
Arguments:
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
C++ macro code (or path to |
|
|
No |
Arguments to pass to the macro function |
|
|
No |
Execution timeout in seconds |
Example:
{
"tool": "run_root_macro",
"arguments": {
"macro": "void myMacro() { TFile *f = TFile::Open(\"data.root\"); f->ls(); }",
"timeout": 30
}
}
Response:
{
"data": {
"stdout": "TFile**\t\tdata.root\n...",
"stderr": "",
"return_code": 0,
"execution_time_s": 0.8
}
}
Tool Summary
By Mode
Core Mode (9 tools)
list_files- List ROOT filesinspect_file- Inspect file structurelist_branches- List TTree branchesvalidate_file- Check file integrityread_branches- Read branch dataget_branch_stats- Compute statisticsexport_data- Export to JSON/CSV/Parquetswitch_mode- Change server modeget_server_info- Get server capabilities
Extended Mode (8 additional tools)
compute_histogram- 1D histogram with fittingcompute_histogram_2d- 2D histogramfit_histogram- Model fittingcompute_invariant_mass- Invariant mass calculationcompute_correlation- Statistical correlationshistogram_arithmetic- Histogram mathplot_histogram_1d- 1D plottingplot_histogram_2d- 2D plotting
Native ROOT Tools (3 optional tools — ROOT installation + enable_root: true)
run_root_code- Arbitrary PyROOT/Python code executionrun_rdataframe- RDataFrame histogram computationrun_root_macro- C++ ROOT macro execution
By Category
File Operations
list_files,inspect_file,validate_file
Data Access
list_branches,read_branches,get_branch_stats
Data Export
export_data
Visualization
plot_histogram_1d,plot_histogram_2d
Histograms
compute_histogram,compute_histogram_2d,fit_histogram
Kinematics
compute_invariant_mass
Statistics
get_branch_stats,compute_correlation
Server Management
switch_mode,get_server_info
Native ROOT
run_root_code,run_rdataframe,run_root_macro
Common Patterns
Exploration Workflow (Core Mode)
// 1. List available files
{"tool": "list_files", "arguments": {}}
// 2. Inspect file structure
{"tool": "inspect_file", "arguments": {"path": "/data/sample.root"}}
// 3. List branches
{"tool": "list_branches", "arguments": {"path": "/data/sample.root", "tree_name": "events"}}
// 4. Read data
{"tool": "read_branches", "arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branches": ["muon_pt", "muon_eta"],
"limit": 100
}}
Analysis Workflow (Extended Mode)
// 1. Switch to extended mode
{"tool": "switch_mode", "arguments": {"mode": "extended"}}
// 2. Compute invariant mass
{"tool": "compute_invariant_mass", "arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"pt_branches": ["muon1_pt", "muon2_pt"],
"eta_branches": ["muon1_eta", "muon2_eta"],
"phi_branches": ["muon1_phi", "muon2_phi"]
}}
// 3. Create histogram with fit
{"tool": "compute_histogram", "arguments": {
"path": "/data/sample.root",
"tree_name": "events",
"branch": "dimuon_mass",
"bins": 100,
"range": [2.8, 3.4],
"fit_model": "gaussian"
}}
// 4. Generate plot
{"tool": "plot_histogram_1d", "arguments": {
"data": {...},
"output_path": "/exports/plot.png"
}}
Error Handling
Mode Errors
If you try to use an extended tool in core mode:
{
"error": "mode_error",
"message": "Tool 'fit_histogram' requires extended mode. Current mode: core",
"hint": "Use switch_mode tool to enable extended mode"
}
Security Errors
If path is not in allowed roots:
{
"error": "security_error",
"message": "Path '/unauthorized/file.root' not in allowed roots",
"allowed_roots": ["/data", "/exports"]
}
Validation Errors
If arguments are invalid:
{
"error": "validation_error",
"message": "Invalid bin count: must be between 1 and 10000",
"field": "bins",
"value": 50000
}
See Also
Mode Selection Guide: Detailed mode comparison
Configuration Guide: Server configuration
Architecture: System design
LLM Integration: Using with AI assistants