root_mcp.core.tools package

Core MCP tools for file operations.

class root_mcp.core.tools.DataAccessTools(config, file_manager, path_validator, tree_reader)[source]

Bases: object

Tools for accessing TTree or RNTuple data.

Parameters:
__init__(config, file_manager, path_validator, tree_reader)[source]

Initialize data access tools.

Parameters:
  • config (Config) – Server configuration

  • file_manager (FileManager) – File manager instance

  • path_validator (PathValidator) – Path validator instance

  • tree_reader (TreeReader) – Tree reader instance

get_branch_stats(path, tree, branches, selection=None)[source]

Compute statistics for branches.

Parameters:
  • path (str) – File path

  • tree (str) – Tree name

  • branches (list[str]) – Branches to analyze

  • selection (str | None) – Optional cut expression

Returns:

Branch statistics

Return type:

dict[str, Any]

read_branches(path, tree_name, branches, selection=None, limit=None, offset=0, entry_start=None, entry_stop=None, flatten=False, defines=None)[source]

Read branch data from a TTree or RNTuple.

Parameters:
  • path (str) – File path

  • tree_name (str) – Tree name

  • branches (list[str]) – List of branch names (can include derived branches from defines)

  • selection (str | None) – Optional cut expression

  • limit (int | None) – Maximum entries to return (alternative to entry_stop)

  • offset (int) – Number of entries to skip (alternative to entry_start)

  • entry_start (int | None) – Start entry index (alternative to offset)

  • entry_stop (int | None) – Stop entry index (alternative to limit)

  • flatten (bool) – Flatten jagged arrays

  • defines (dict[str, str] | None) – Optional derived variable definitions {name: expression}

Returns:

Branch data and metadata

Return type:

dict[str, Any]

sample_tree(path, tree, size=100, method='first', branches=None, seed=None)[source]

Get a sample from a tree.

Parameters:
  • path (str) – File path

  • tree (str) – Tree name

  • size (int) – Sample size

  • method (str) – “first” or “random”

  • branches (list[str] | None) – Branches to include (None = all)

  • seed (int | None) – Random seed

Returns:

Sample data and metadata

Return type:

dict[str, Any]

class root_mcp.core.tools.DiscoveryTools(config, file_manager, path_validator)[source]

Bases: object

Tools for discovering and inspecting ROOT files.

Parameters:
__init__(config, file_manager, path_validator)[source]

Initialize discovery tools.

Parameters:
  • config (Config) – Server configuration

  • file_manager (FileManager) – File manager instance

  • path_validator (PathValidator) – Path validator instance

inspect_file(path, include_histograms=True, include_trees=True)[source]

Inspect a ROOT file’s structure.

Parameters:
  • path (str) – File path

  • include_histograms (bool) – Include histogram metadata

  • include_trees (bool) – Include tree metadata

Returns:

File structure and metadata

Return type:

dict[str, Any]

list_branches(path, tree_name, pattern=None, limit=100, include_stats=False)[source]

List branches in a TTree or RNTuple.

Parameters:
  • path (str) – File path

  • tree_name (str) – Tree name

  • pattern (str | None) – Glob pattern to filter branches

  • limit (int) – Maximum branches to return

  • include_stats (bool) – Compute statistics (slower)

Returns:

Branch information

Return type:

dict[str, Any]

list_files(resource=None, pattern=None, limit=100)[source]

List ROOT files in a resource.

Parameters:
  • resource (str | None) – Resource ID (None = default)

  • pattern (str | None) – Glob pattern to filter files

  • limit (int) – Maximum files to return

Returns:

List of files with metadata

Return type:

dict[str, Any]

Submodules