root-mcp

MCP server for ROOT CERN files

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.

Quick Start

1. Install

pip install root-mcp

Optional: For remote file access via XRootD protocol:

pip install "root-mcp[xrootd]"

2. Configure

Create a config.yaml and set your preferred mode:

# Server settings
server:
  name: "root-mcp"
  mode: "extended"  # Options: "core" or "extended"

# Data resources
resources:
  - name: "my_analysis"
    uri: "file:///Users/me/data"
    allowed_patterns: ["*.root"]

# Security
security:
  allowed_roots:
    - "/Users/me/data"

# Output directory for exports
output:
  export_base_path: "/Users/me/exports"

Mode Selection:

  • mode: "core" - Lightweight mode for file operations and basic statistics
  • mode: "extended" - Full analysis features (histograms, fitting, kinematics, correlations)

You can switch modes at runtime using the switch_mode tool without restarting the server.

3. Run with Claude Desktop

Add to your claude_desktop_config.json:

{
  "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.

Related Servers