Skip to main content

Model Context Protocol server for xraylib X-ray interaction data

Project description

xraylib MCP Server

CI Docker Docker Image PyPI License: BSD-3-Clause

A Model Context Protocol (MCP) server that provides access to xraylib X-ray interaction data through a standardized interface. Query cross-sections, fluorescence lines, edge energies, and more from any MCP-compatible client.

Features

This server exposes 101 tools organized into the following categories:

Utility tools

  • AtomicNumberToSymbol / SymbolToAtomicNumber -- convert between atomic numbers and element symbols
  • AtomicWeight -- atomic weight (g/mol)
  • ElementDensity -- element density (g/cm3)
  • ElectronConfig -- electron configuration for a given shell
  • CompoundParser -- parse chemical formulas (e.g. SiO2, Ca5(PO4)3F)
  • Atomic_Factors -- atomic scattering factors f0, f', f''

Line, edge, and shell properties

  • LineEnergy / EdgeEnergy -- fluorescence line and absorption edge energies (keV)
  • FluorYield / JumpFactor / RadRate -- fluorescence yields, jump factors, radiative rates
  • AtomicLevelWidth -- natural widths of atomic levels (keV)

Cross-sections (element)

  • CS_Total, CS_Photo, CS_Rayl, CS_Compt, CS_Energy, CS_KN -- mass cross-sections (cm2/g)
  • CSb_Total, CSb_Photo, CSb_Rayl, CSb_Compt -- atomic cross-sections (barn/atom)

Fluorescence cross-sections

  • CS_FluorLine / CSb_FluorLine -- line fluorescence cross-sections
  • CS_FluorShell / CSb_FluorShell -- shell fluorescence cross-sections
  • Kissel photoionization variants with full, radiative, nonradiative, and no cascade options

Differential cross-sections

  • DCS_Rayl / DCS_Compt and barn/atom variants -- unpolarized differential cross-sections
  • DCSP_Rayl / DCSP_Compt and barn/atom variants -- polarized differential cross-sections

Scattering factors

  • FF_Rayl / SF_Compt -- Rayleigh form factor and Compton scattering function
  • MomentTransf / ComptonEnergy -- momentum transfer and Compton-scattered photon energy
  • Fi / Fii -- anomalous scattering factors
  • ComptonProfile / ComptonProfile_Partial -- Compton profiles (total and per-shell)

Auger and Coster-Kronig transitions

  • AugerRate / AugerYield -- Auger transition rates and yields
  • CosKronTransProb -- Coster-Kronig transition probabilities

Compound cross-sections

  • All CS/CSb, DCS/DCSb, and DCSP/DCSPb variants for compounds (by chemical formula)
  • Kissel photoionization variants for compounds

Refractive index

  • Refractive_Index_Re / Refractive_Index_Im -- real and imaginary parts of the refractive index

NIST compounds

  • GetCompoundDataNISTByName / GetCompoundDataNISTByIndex / GetCompoundDataNISTList -- access the built-in NIST compound database

Constant listings

  • ListLineConstants / ListShellConstants / ListTransitionConstants / ListAugerConstants / ListNISTCompoundConstants -- enumerate valid constant names

Installation

Using uv (recommended)

uv tool install xraylib-mcp-server

Using pip

pip install xraylib-mcp-server

Usage

As a standalone server

# Run with stdio transport (for Claude Desktop, etc.)
xraylib-mcp-server

# Run with HTTP transport
xraylib-mcp-server --transport http --port 8000

# Run with SSE transport
xraylib-mcp-server --transport sse --port 8000

With Claude Desktop

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "xraylib": {
      "command": "uvx",
      "args": ["xraylib-mcp-server"]
    }
  }
}

Or using the pre-built Docker image:

{
  "mcpServers": {
    "xraylib": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "ghcr.io/tschoonj/xraylib-mcp:latest"]
    }
  }
}

With VS Code

Add to your VS Code settings (.vscode/settings.json or user settings):

{
  "mcp.servers": {
    "xraylib": {
      "command": "uvx",
      "args": ["xraylib-mcp-server"]
    }
  }
}

Or using the pre-built Docker image:

{
  "mcp.servers": {
    "xraylib": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "ghcr.io/tschoonj/xraylib-mcp:latest"]
    }
  }
}

As a development server

# Run in development mode with MCP inspector
uv run mcp dev src/xraylib_mcp_server/server.py

Using Docker

Pre-built images from GitHub Container Registry

# Pull the latest image
docker pull ghcr.io/tschoonj/xraylib-mcp:latest

# Run with stdio transport
docker run -i --rm ghcr.io/tschoonj/xraylib-mcp:latest

# Run with HTTP transport on port 8000
docker run --rm -p 8000:8000 ghcr.io/tschoonj/xraylib-mcp:latest xraylib-mcp-server --transport http --port 8000

# Use a specific version
docker pull ghcr.io/tschoonj/xraylib-mcp:0.1.0
docker run -i --rm ghcr.io/tschoonj/xraylib-mcp:0.1.0

Local development with Docker

# Build the Docker image locally
docker build -t xraylib-mcp-server .

# Run with stdio transport
docker run -i --rm xraylib-mcp-server

# Run with HTTP transport on port 8000
docker run --rm -p 8000:8000 xraylib-mcp-server xraylib-mcp-server --transport http --port 8000

Development

Setup

# Clone the repository
git clone https://github.com/tschoonj/xraylib-mcp.git
cd xraylib-mcp

# Install development dependencies
uv sync --dev

Running tests

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=src/xraylib_mcp_server --cov-report=html

Code quality

# Lint
uv run ruff check .

# Format
uv run ruff format .

# Type check
uv run mypy src/ --ignore-missing-imports

License

BSD 3-Clause License -- see LICENSE for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xraylib_mcp_server-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xraylib_mcp_server-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file xraylib_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: xraylib_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for xraylib_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b695063b18a0a54712729f5c11e0f6215d539464062a5f217f044d6bd5d380d
MD5 7fb7f85f99993bd1edcee7238749dba4
BLAKE2b-256 ba601c8a159eeb925471e25cc8fdb9070c95ffc190d83f5918ca957854c22026

See more details on using hashes here.

Provenance

The following attestation bundles were made for xraylib_mcp_server-0.1.0.tar.gz:

Publisher: ci.yml on tschoonj/xraylib-mcp-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xraylib_mcp_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xraylib_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e6a0427697635f3b74c0a217d4aad928b02b652db4fb93c4d4f1fcaf57a6e73
MD5 6d062bd698a43690ac9302863838f396
BLAKE2b-256 b260a7e99534a989ec9440a4b0fdd3608fe94d0848837904e82a7445c0814e5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for xraylib_mcp_server-0.1.0-py3-none-any.whl:

Publisher: ci.yml on tschoonj/xraylib-mcp-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page