CERN ROOT MCP Server

CERN ROOT MCP Server

An MCP server and CLI tool that allow LLMs to interact with CERN ROOT files.

Category
访问服务器

README

<p align="center"> <img src="https://raw.githubusercontent.com/MohamedElashri/root-mcp/main/root-mcp_logo.png" alt="CERN ROOT MCP Server" width="160" /> </p>

<h1 align="center">CERN ROOT MCP Server</h1>

<p align="center"> An <a href="https://modelcontextprotocol.io/">MCP</a> server and <strong>CLI tool</strong> that allow LLMs to interact with CERN ROOT files. </p>

CI PyPI License Language

Repository Mirror: This repository is mirrored to CERN GitLab for CERN users. PyPI releases are published via GitHub Actions using attestation-based trusted publishing.

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) or a token-efficient <strong>CLI interface</strong>, it turns Claude (and other MCP-compliant agents) into capable physics research assistants that can:

  • Inspect ROOT file structures (Trees, RNTuples, 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.


Two Interfaces: MCP Server and CLI

ROOT-MCP provides two ways to interact with ROOT files:

1. MCP Server (for Claude Desktop and MCP clients)

  • Full JSON-RPC protocol support
  • Structured input/output for programmatic use
  • Best for: MCP-compliant LLM clients, automated workflows

2. ROOT CLI (root-cli)

  • Human-readable output by default
  • Simpler architecture (no server process)
  • Best for: Direct LLM interaction, debugging, scripting

Both interfaces share the same backend and support all 17 analysis tools.


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:

# MCP Server
root-mcp --data-path /path/to/your/data

# CLI (token-efficient)
root-cli -d /path/to/your/data ls

Or set an environment variable once:

export ROOT_MCP_DATA_PATH=/path/to/your/data

ROOT CLI (Recommended for LLM Interaction)

The CLI provides a token-efficient, human-readable interface that provides significant token savings compared to the MCP JSON protocol.

Basic Usage

# List files
root-cli ls

# Inspect a file
root-cli inspect /data/sample.root

# Create histogram with fit
root-cli histogram /data/sample.root events muon_pt --bins 100 --fit gaussian

# Read data with selection
root-cli read /data/sample.root events met muon_pt --selection "met > 50"

# Plot results
root-cli plot1d /tmp/root_mcp/muon_pt_hist.json -o plot.png --title "Muon pT"

Example LLM Workflow

Ask your LLM: "Plot the muon pT distribution"

The LLM generates:

root-cli histogram /data/sample.root events muon_pt --bins 50 && \
root-cli plot1d /tmp/root_mcp/muon_pt_hist.json -o muon_pt.png --title "Muon pT Distribution"

Documentation

See docs/skills/root-cli.md for complete command reference with examples.


MCP Server

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.

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"
      }
    }
  }
}

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}
}

Documentation

The full documentation site is built with Sphinx and covers installation, configuration, all 20 MCP tools, LLM integration patterns, and the developer guide with auto-generated API reference.

Read online: The docs are hosted at root-mcp docs

pip install "root-mcp[docs]"
./scripts/build_docs.sh
# open docs/_build/html/index.html

For live-reload while writing docs:

cd docs && make livehtml

Highlights:

  • User Guide — installation, quickstart, modes, configuration, LLM integration
  • Tool Reference — complete catalogue of all tools and their JSON payloads
  • CLI Reference — complete command reference for root-cli with examples
  • Developer Guide — architecture, module overview, dev setup, contributing
  • API Reference — auto-generated from source docstrings

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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选