Skip to main content

Production-grade MCP server for CERN ROOT file analysis

Project description

ROOT-MCP: LLM Powered HEP Analysis

CI PyPI License Language

ROOT-MCP empowers Large Language Models (LLMs) to natively understand and analyze CERN ROOT files.

By exposing a set of specialized tools via the Model Context Protocol (MCP), it turns Claude (and other MCP-compliant agents) into capable physics research assistants that can:

  • Inspect ROOT file structures (Trees, Branches, Histograms)
  • Analyze data distributions (Compute Histograms, Statistics)
  • Compute kinematic quantities (Invariant Mass)
  • Visualize results (Plot 1D/2D histograms directly)
  • Filter data using physics cuts ("selections")

Why this matters: Instead of asking an LLM to "write a script" that you have to debug and run, you can ask the LLM to "Check the muon pT distribution in this file" and it will just do it.


Architecture

ROOT-MCP features a dual-mode architecture:

  • Core Mode: File I/O, data reading, and basic statistics
  • Extended Mode: Full analysis capabilities including fitting, kinematics, and correlations

The mode is controlled via configuration, and the server automatically loads only the components you need. Runtime mode switching is also available.

Optional Native ROOT Support

ROOT-MCP can optionally integrate with a native ROOT/PyROOT installation to unlock capabilities beyond what uproot provides:

  • run_root_code: Execute arbitrary PyROOT/Python code and get structured results
  • run_rdataframe: Compute histograms using ROOT's RDataFrame (no boilerplate needed)
  • run_root_macro: Execute C++ ROOT macros via gROOT.ProcessLine

This feature is entirely optional — ROOT-MCP works fully without ROOT installed. When ROOT is available and enabled, these additional tools appear automatically.

Requirements: A working ROOT installation (via conda-forge, system package, or binary tarball). ROOT is not pip-installable at this time.

Enable it by setting enable_root: true in your config.yaml:

features:
  enable_root: true

# Optional: tune execution settings
root_native:
  execution_timeout: 60
  working_directory: "/tmp/root_mcp_native"

Use get_server_info to check ROOT availability at runtime:

{
  "root_native_available": true,
  "root_native_enabled": true,
  "root_version": "6.32/02",
  "root_features": {"rdataframe": true, "roofit": true, "tmva": false}
}

Quick Start

1. Install

pip install root-mcp

Optional: For remote file access via XRootD protocol:

pip install "root-mcp[xrootd]"

2. Configure

Fastest path — no config file needed:

root-mcp --data-path /path/to/your/data

Or set an environment variable once:

export ROOT_MCP_DATA_PATH=/path/to/your/data

Zero-config one-liners:

# Core mode (lightweight, no scipy/matplotlib needed)
root-mcp --data-path /data --mode core

# Extended mode with native ROOT, restricted to one directory
root-mcp --data-path /data --enable-root --allowed-root /data

# Remote XRootD resource, no YAML needed
root-mcp --resource cms=root://xrootd.cern.ch//store --allow-remote --mode extended

# Docker / container — fully env-var driven
ROOT_MCP_DATA_PATH=/data ROOT_MCP_MODE=extended ROOT_MCP_EXPORT_PATH=/exports root-mcp

# Quiet server (only warnings+) with a cache increase
root-mcp --data-path /data --log-level WARNING --cache-size 100

Generate a starter config (optional):

root-mcp init --permissive   # creates config.yaml pre-filled with current directory

Manual config file — for persistent settings, remote resources, or native ROOT:

server:
  mode: "extended"   # "core" or "extended"

resources:
  - name: "my_analysis"
    uri: "file:///path/to/data"
    allowed_patterns: ["*.root"]

security:
  allowed_roots: []  # empty = any local path is accessible (permissive)

Mode Selection:

  • mode: "core" — Lightweight: file operations and basic statistics
  • mode: "extended" — Full analysis: histograms, fitting, kinematics, correlations

Switch modes at runtime with the switch_mode tool — no restart required.

3. Run with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "root-mcp": {
      "command": "root-mcp",
      "args": ["--data-path", "/path/to/your/data"]
    }
  }
}

Or with a persistent config file:

{
  "mcpServers": {
    "root-mcp": {
      "command": "root-mcp",
      "env": {
        "ROOT_MCP_CONFIG": "/path/to/config.yaml"
      }
    }
  }
}

Documentation

Citation

If you use ROOT-MCP in your research, please cite:

@software{root_mcp,
  title = {ROOT-MCP: Production-Grade MCP Server for CERN ROOT Files},
  author = {Mohamed Elashri},
  year = {2025},
  url = {https://github.com/MohamedElashri/root-mcp}
}

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

root_mcp-0.1.5.tar.gz (106.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

root_mcp-0.1.5-py3-none-any.whl (101.0 kB view details)

Uploaded Python 3

File details

Details for the file root_mcp-0.1.5.tar.gz.

File metadata

  • Download URL: root_mcp-0.1.5.tar.gz
  • Upload date:
  • Size: 106.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for root_mcp-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a0c3d0fa7e6fdf0b630e75af03f2a3712ac89a25f1e11251c48bdcc3df4d13c8
MD5 b362a55d68d9a4e2b25c2d089e4f5d6b
BLAKE2b-256 a45f463f35dc8e30920dd36d694a64e7f24fb7f84c9bde39248b18b64becc44d

See more details on using hashes here.

Provenance

The following attestation bundles were made for root_mcp-0.1.5.tar.gz:

Publisher: release.yml on MohamedElashri/root-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file root_mcp-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: root_mcp-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 101.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for root_mcp-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 185af75fdcf8cc90313eb9b33ad518d515aea60a43ab285cc50f98862dd77e2f
MD5 1a8b4a345bf0c0487c575986ce4bb2f2
BLAKE2b-256 f86e8d3d4a875ec9b4d4c958b7d361004a4d638e73054fee513fcdcaea49cc4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for root_mcp-0.1.5-py3-none-any.whl:

Publisher: release.yml on MohamedElashri/root-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page