Skip to content

feat: MCP server design spike — expose UnifiedFittingConfig via Model Context Protocol #2082

@Anselmoo

Description

@Anselmoo

Summary

Design and implement a Model Context Protocol (MCP) server that exposes SpectraFit's fitting pipeline as LLM-callable tools.

Prerequisite

  • Phases 1–5 complete — UnifiedFittingConfig is stable with JSON Schema via model_json_schema()
  • FitResult(BaseModel) added in Phase 8 — stable, serialisable JSON output
  • BatchFittingConfig(BaseModel) added in Phase 8 — multi-spectrum parallel fitting

Proposed Tools

Tool Input Output
fit_spectrum UnifiedFittingConfig JSON FitResult JSON
batch_fit BatchFittingConfig JSON list[FitResult] JSON
validate_config Raw dict Validation errors or schema
list_models None Available peak model names
get_schema Model name JSON Schema for that model

Technical Notes

  • Use FastMCP or the official MCP Python SDK
  • UnifiedFittingConfig.model_json_schema() is the stable API surface for input schema
  • FitResult.model_json_schema() is the stable API surface for output schema
  • Transport: stdio (default) + optional http/sse for remote access
  • Authentication: API key via environment variable SPECTRAFIT_MCP_API_KEY

Acceptance Criteria

  • MCP server starts with python -m spectrafit.mcp or spectrafit-mcp
  • fit_spectrum tool validates input against UnifiedFittingConfig schema
  • fit_spectrum tool returns FitResult as JSON
  • batch_fit tool accepts BatchFittingConfig and returns list of results
  • Server tested with Claude Desktop or another MCP client
  • Documentation added to docs/mcp.md

References

  • MCP Python SDK
  • FastMCP
  • spectrafit/models/fit_result.py — FitResult model
  • spectrafit/core/fitting_config.py — UnifiedFittingConfig

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions