root_mcp.extended.tools.root_native module

MCP tool for executing native ROOT/PyROOT code.

class root_mcp.extended.tools.root_native.RootNativeTools(config)[source]

Bases: object

MCP tool handler for native ROOT/PyROOT code execution.

This tool is only registered when both: - config.features.enable_root is True - Native ROOT/PyROOT is detected as available

Parameters:

config (Config) – Server configuration.

__init__(config)[source]
Parameters:

config (Config)

Return type:

None

run_rdataframe(file_path, tree_name, branch, bins, range_min, range_max, selection=None, weight=None, output_path=None, timeout=None)[source]

Compute a 1D histogram using RDataFrame.

This is a convenience wrapper around run_root_code that generates RDataFrame code from parameters, avoiding the need to write PyROOT boilerplate.

Parameters:
  • file_path (str) – Path to the ROOT file.

  • tree_name (str) – Name of the TTree or RNTuple.

  • branch (str) – Branch to histogram.

  • bins (int) – Number of bins.

  • range_min (float) – Histogram range.

  • range_max (float) – Histogram range.

  • selection (str | None) – Optional cut expression (C++ syntax).

  • weight (str | None) – Optional weight column name.

  • output_path (str | None) – If provided, save histogram plot to this path.

  • timeout (int | None) – Execution timeout in seconds.

Returns:

Structured result with histogram data.

Return type:

dict

run_root_code(code, output_dir=None, timeout=None, input_files=None)[source]

Execute PyROOT/Python code and return structured results.

Parameters:
  • code (str) – Python code to execute (may import ROOT).

  • output_dir (str | None) – Directory for output files (optional).

  • timeout (int | None) – Execution timeout in seconds (optional, overrides config default).

  • input_files (list[str] | None) – Paths to ROOT files the code needs access to.

Returns:

Structured result with status, stdout, stderr, output_files, etc.

Return type:

dict

run_root_macro(macro_code, output_path=None, timeout=None)[source]

Execute a ROOT C++ macro via gROOT.ProcessLine.

Parameters:
  • macro_code (str) – C++ code to execute.

  • output_path (str | None) – If provided, save any canvas output to this path.

  • timeout (int | None) – Execution timeout in seconds.

Returns:

Structured result.

Return type:

dict