xraylarch-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
xraylarch-mcp
MCP (Model Context Protocol) server that wraps xraylarch for X-ray spectroscopy analysis. Load, process, analyze, and plot XAS/XAFS spectra through Claude Desktop or Claude Code with natural language tool calls. Supports XANES normalization, EXAFS extraction, Fourier transforms, linear combination fitting, PCA, FEFFIT shell fitting, and publication-quality plotting.
Installation
pip install xraylarch-mcpRequires Python 3.11 or newer. The server is built on version 2 of the MCP Python SDK (mcp>=2).
Related MCP server: fdmnes-mcp
Configuration
Claude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"xraylarch": {
"command": "python",
"args": ["-m", "xraylarch_mcp"]
}
}
}Claude Code
claude mcp add xraylarch -- python -m xraylarch_mcpQuick Start
Ask Claude:
"Load the spectrum at ~/data/fe_foil.xdi and show me the normalized XANES"
Claude will:
Call
larch_load_spectrumto read your dataCall
larch_normalizeto perform pre-edge subtraction and normalizationCall
larch_plotwithplot_type="norm"to generate a publication-quality plot
Tool Reference
I/O Tools
Tool | Description |
| Load a spectrum from file (.xdi, .dat, .csv, .prj, etc.) |
| Read/inspect Athena project files |
| List all loaded spectrum groups |
| Detailed view of a group's arrays and scalars |
| Remove a group to free memory |
XAFS Analysis Tools
Tool | Description |
| Pre-edge subtraction and normalization (wraps |
| EXAFS background removal (AUTOBK algorithm) |
| Forward Fourier transform: chi(k) -> chi(R) |
| Back Fourier transform: chi(R) -> chi(q) |
| Fluorescence self-absorption correction |
| MBACK normalization (alternative for problematic data) |
| Noise estimation in chi(k) and chi(R) |
| Cauchy wavelet transform for simultaneous k- and R-resolution |
| Rebin to standard 3-region XAFS energy grid |
Plot Tools
Tool | Description |
| Publication-quality plots (mu, norm, flat, dmude, chi_k, chi_r, chi_q, cauchy_wavelet) |
Math Tools
Tool | Description |
| Smooth arrays with Lorentzian/Gaussian/Voigt kernel |
| Numerical derivative |
| Interpolate onto new energy grid |
| Merge/average multiple spectra |
| Remove glitch points |
Fitting Tools
Tool | Description |
| Linear combination fitting against standards |
| Principal Component Analysis |
| FEFFIT EXAFS shell fitting |
| Peak fitting (Gaussian, Voigt, etc.) |
Interactive Tools
Tool | Description |
| Open an interactive HTML page to tune normalization parameters |
| Apply normalization parameters from a saved JSON file |
Interactive normalization workflow
Ask Claude to interactively normalize your spectrum
An HTML page opens in your browser with Plotly.js plots and sliders
Adjust E0, pre-edge range, post-edge range, and polynomial degree — plots update in real time
Click Save Parameters to download a JSON file, or Copy to Clipboard
Tell Claude to apply the saved parameters
"Load Pdfoil.prj and let me interactively choose the normalization parameters"
Advanced
Tool | Description |
| Execute arbitrary Python code in the larch session |
Resources
The server exposes documentation resources that Claude can read on demand:
larch://docs/xafs— XAFS analysis referencelarch://docs/io— I/O functions referencelarch://docs/fitting— Fitting referencelarch://docs/feff— FEFF interface referencelarch://docs/interactive— Interactive tools referencelarch://docs/examples/xanes— XANES workflow examplelarch://docs/examples/exafs— EXAFS workflow example
Links
Releasing
Releases go to PyPI from GitHub Actions (.github/workflows/publish.yml), with
no token: PyPI trusts this repository's workflow directly.
Set the new version in
pyproject.tomlandsrc/xraylarch_mcp/__init__.py, and merge that tomain.Tag the merge commit and push the tag, e.g.
git tag v0.4.1 && git push origin v0.4.1, or publish a GitHub release with a new tagv0.4.1.
The workflow runs the tests, checks that the tag matches both version strings, builds the package and uploads it.
One-time setup: in the project's PyPI settings under Publishing, add a GitHub publisher with owner Joint-Photon-Sciences-Institute,
repository xraylarch-mcp, workflow publish.yml and environment pypi.
License
BSD-3-Clause (matching xraylarch)
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
This MCP server enables users to perform scientific computations regarding linear algebra and vect…
MCP server for generating rough-draft project plans from natural-language prompts.
Related MCP Servers
- AlicenseBqualityDmaintenanceA standalone MCP server that enables research (web search, URL fetch, news), workspace management (file operations, command execution), and self-extension via markdown-based skills.21MIT
- AlicenseNot gradedqualityDmaintenanceEnables running FDMNES X-ray spectroscopy simulations via natural language, supporting input file creation, job execution, output analysis, and keyword lookup through MCP-aware clients.2BSD 3-Clause
- AlicenseBqualityCmaintenanceAn MCP server and CLI tool that allow LLMs to interact with CERN ROOT files.9127 PyPI4MIT
- FlicenseNot gradedqualityDmaintenancePrototype of a Model Context Protocol (MCP) server that provides access to X-ray properties of elements via the XrayDB library.-