
ROOT MCP Server
io.github.omazapa由 GitHub 帳號 omazapa 發布v1.0.0更新於 Oct 24, 2026
ROOT-based MCP server exposing root_python and root_cpp tools (stdio transport).
概覽
本機 MCP 伺服器,透過 CERN ROOT/PyROOT 在行程內執行 Python 與 C++ 程式碼,並回傳標準輸出、錯誤輸出與錯誤資訊。
- 可以做什麼
- 執行已自動載入 ROOT 的 Python 程式碼,回傳 stdout、stderr 與錯誤中繼資料
- 透過 ROOT 的 cling 解譯器執行 C++ 程式碼,並依回傳碼與 stderr 偵測編譯錯誤
- 建立直方圖、畫布等 ROOT 繪圖物件,支援事件迴圈,並可啟用內嵌 HTTP 伺服器檢視互動式畫布
- 將每次執行的含行號程式碼與結果記錄到 MCP 主控台
- 適用情境
- 適合讓助理在本機直接執行以 ROOT 為基礎的資料分析、直方圖統計或繪圖程式碼,例如在 VS Code 搭配 Copilot Chat 時,而不只是產生程式碼讓你自己執行。
- 執行需求
- 以本機 stdio 行程執行(Docker 映像或 pip 安裝)。需要 ROOT 6.x 或更新版本並啟用 PyROOT、Python 3.10+,啟動前還需載入 ROOT 環境(例如 thisroot.sh)。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 ROOT MCP Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
root_mcp_server: MCP Server for ROOT
Model Context Protocol server for executing Python and C++ code with PyROOT
Minimal MCP (Model Context Protocol) server that allows LLMs and other MCP clients to execute Python and C++ code directly using PyROOT, without HTTP endpoints or external APIs.
Features
- Direct Python execution: Run Python code with PyROOT available automatically
- Direct C++ execution: Run C++ code via ROOT's cling interpreter
- In-process: All code runs in the same process (no subprocess isolation)
- Error detection: Automatic detection of C++ compilation errors via return codes and stderr
- Console logging: Pretty-printed code execution with results in MCP console
- Graphics support: TCanvas and ROOT graphics objects with event loop support
Architecture
Below is the architecture diagram for the root_mcp_server project. The image contains a visual representation of the components and their interactions.
Description:
- MCP Client (VS Code / CLI / Programmatic): connects to the MCP server and sends execution requests. Clients can be interactive (e.g. VS Code + Copilot Chat) or scripted CLI clients.
- FastMCP Server: receives MCP tool calls (
root_python,root_cpp) and dispatches them to the in-process executor. - RootExecutor (in-process PyROOT): runs Python or C++ code with the ROOT runtime, manages graphics mode, and can expose an embedded HTTP server (THttpServer) for interactive canvases.
- ROOT Web Canvas (THttpServer / JSROOT): when graphics are enabled, canvases created in the ROOT session are available via the embedded HTTP server; clients can open the provided URL to inspect plots interactively.
- Artifacts & Outputs: execution results (stdout/stderr and error metadata) are returned to the MCP client; interactive canvases are accessible via the HTTP endpoint.
This architecture keeps ROOT running in-process for low-latency execution while providing a web-backed path for interactive visualization.
Installation
Prerequisites
- ROOT (6.x or later) with PyROOT enabled
- Python 3.10+
Install the package
Usage
Option 1: VS Code with GitHub Copilot Chat
The easiest way to use this MCP server is through VS Code with GitHub Copilot Chat.
1. Install GitHub Copilot Chat extension
Make sure you have the GitHub Copilot Chat extension installed in VS Code.
2. Configure MCP server in VS Code
Add the MCP server configuration to your VS Code settings. Open your settings.json (Ctrl/Cmd + Shift + P → "Preferences: Open User Settings (JSON)") and add:
Important: Replace /path/to/ROOT/build/bin/thisroot.sh with the actual path to your ROOT installation's thisroot.sh script.
3. Use in Copilot Chat
Once configured, you can use the MCP tools in GitHub Copilot Chat:
The server will automatically log executed code and results to the MCP console (visible in VS Code's Output panel).
Option 2: Command line
Start the MCP server directly:
Option 3: Programmatic usage
Available Tools
The server exposes two MCP tools:
1. root_python
Execute Python code with ROOT automatically available in scope.
Arguments:
code(string): Python code to execute
Returns:
Example:
2. root_cpp
Execute C++ code via ROOT's cling interpreter.
Arguments:
code(string): C++ code to execute
Returns:
Example:
Features in Detail
Error Detection
The server automatically detects C++ compilation errors by:
- Checking the return code from
ROOT.gInterpreter.ProcessLine() - Scanning stderr for error keywords (
error:,Error:,fatal error:)
Errors are reported with ok=false and detailed error messages.
Console Logging
All code execution is logged to stderr (MCP console) with:
- Pretty-printed code with line numbers
- Execution status (✓ success / ❌ failure)
- Complete stdout, stderr, and error details
Example output:
Graphics Support
The server initializes TApplication and supports ROOT graphics:
- TCanvas windows (batch mode can be disabled)
- Histogram plotting
- ROOT event loop for interactive graphics
- Object persistence to prevent garbage collection
Development
Running tests
Project Structure
License
See LICENSE file.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Built with the Model Context Protocol
- Powered by ROOT from CERN
來源:README.md,提交 0dd2d95
工具
0版本歷史
1- v1.0.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分