MCP Refana Server
Enables Mu2e analysis workflows by exposing event counting, cut analysis, sensitivity computation, and ML selection as MCP tools for agentic frameworks.
README
MCP Refana Server
Model Context Protocol (MCP) server for Mu2e refana analysis workflows. Exposes core analysis functions as MCP tools for integration with agentic frameworks.
Environment Setup
This project requires the Mu2e analysis environment. On Mu2e gpvm's, activate the environment first:
source /cvmfs/mu2e.opensciencegrid.org/env/ana/current/bin/activate
This provides:
pyutils- Python interface to EventNtupleuproot- ROOT file handlingawkward- Ragged array supportnumpy,scipy,scikit-learn,xgboost,matplotlib
Features
- Event Counting: Signal/background extraction in kinematic regions
- Cut Analysis: Definition and application of analysis cuts
- Sensitivity Computation: Discovery significance, CLs limits, Feldman-Cousins intervals
- ML Selection: BDT-based signal/background discrimination setup
- Analysis Summaries: Dataset-level analysis results
Installation
# Activate Mu2e analysis environment
source /cvmfs/mu2e.opensciencegrid.org/env/ana/current/bin/activate
# Install mcp-refana in development mode
cd mcp-refana
pip install -e .
Running the Server
Important: Always activate the Mu2e environment before running.
# Source Mu2e environment
source /cvmfs/mu2e.opensciencegrid.org/env/ana/current/bin/activate
# Start server with stdio transport (default)
mcp-refana-server --transport stdio
Or with HTTP transport:
source /cvmfs/mu2e.opensciencegrid.org/env/ana/current/bin/activate
mcp-refana-server --transport streamable-http
Available Tools
healthcheck()
Returns server status.
count_signal_background(mom_list, time_list, mc_list, mom_range, time_range, sign)
Extract signal and background event counts in a defined kinematic window.
Parameters:
mom_list: Reconstructed momentum valuestime_list: Reconstructed time valuesmc_list: MC truth labelsmom_range: [min, max] momentum windowtime_range: [min, max] time windowsign: "minus" (electrons) or "plus" (positrons)
Returns: Signal/background counts and statistics
analyze_cuts(cut_definitions, sign)
Initialize analysis cut configuration.
compute_sensitivity(s_expected, b_expected, b_sys_uncertainty, exposure, efficiency)
Compute physics sensitivity metrics:
- Asimov significance Z
- 95% CLs upper limit
- 90% Feldman-Cousins confidence interval
initialize_ml_selector()
Set up machine learning event selector.
get_cut_efficiency(cuts_applied, n_total, n_surviving)
Calculate efficiency metrics for applied cuts.
summarize_analysis(dataset_name, sign, n_events_processed, signal_count, background_count, ml_score_mean)
Generate analysis summary for a dataset.
Integration with HEP-Multiagent
Register this server in the multiagent's config.py:
"refana": {
"command": ["mcp-refana-server", "--transport", "stdio"],
"description": "Mu2e refana analysis server",
}
Then use in worker nodes for agentic analysis workflows.
Architecture
src/mcp_refana/
├── __init__.py
├── server.py # FastMCP server setup
└── mcp_tools/
├── __init__.py
└── refana_wrappers.py # Tool definitions wrapping refana code
The server wraps the core refana analysis classes (Count, Analyze, MLSelect, SensitivityAnalyzer) as MCP tools, making them accessible to agents via tool calls.
Dependencies
- mcp: Model Context Protocol framework
- refana: Core analysis code (count, analyze, ML selection, sensitivity)
- numpy, scipy: Numerical computing
- scikit-learn, xgboost: Machine learning
- uproot, awkward: ROOT file handling
- matplotlib: Visualization
Development
Run tests:
pytest tests/
Format code:
ruff check . --fix
Contact
Sophie Middleton, Huma Jafree
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.