agentleFS
raulkiviraulkivi/sheet-music-mcp/comparer-mcp/CLAUDE.md

sheet-music-mcp / comparer-mcp

CLAUDE.md4 starsChanged 2 months agoMITView on GitHub

Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp Music-aware comparison of two MusicXML files. Provides structured, multi-level diffs from global similarity score down to individual note differences. Primary use cases: version/arrangement comparison, OMR quality evaluation, round-trip fidelity testing. Status: Phase 4 (Advanced features) complete — all originally-scoped phases done. UX Wave 2 (score references) complete. UX Wave 3: options.measure_range renamed to options.measures (and list_changes's measure_range to measures), old names kept as deprecated aliases. MCP Apps Diff Viewer done (ui://comparer/diff-viewer, structuredContent, output schemas,…

  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Remove the aliases in the release after 0.3.0.

    line 97
  2. Very specific:

    Integration tests: must be @pytest.mark.integration

    line 115

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

comparer-mcp — Claude Code Instructions

Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp

What This Server Does

Music-aware comparison of two MusicXML files. Provides structured, multi-level diffs from global similarity score down to individual note differences. Primary use cases: version/arrangement comparison, OMR quality evaluation, round-trip fidelity testing.

Status: Phase 4 (Advanced features) complete — all originally-scoped phases done. UX Wave 2 (score references) complete. UX Wave 3: options.measure_range renamed to options.measures (and list_changes's measure_range to measures), old names kept as deprecated aliases. MCP Apps Diff Viewer done (ui://comparer/diff-viewer, structuredContent, output schemas, diff_id and two app-only tools; page in ui/apps/diff-viewer/). compare_scores (C24) consolidates the five compare tools (detail: summary, changes, report, full); the old names are deprecated aliases for one minor release. 413 unit tests pass (+7 integration, which need the omr-mcp .mxl samples). server.py exposes all 12 tools (two app-only); engine.py/models.py/part_matcher.py/note_aligner.py/measure_comparator.py/report.py/ annotator.py/utils.py are all implemented and independently usable.


Running Tests

# From this directory
VIRTUAL_ENV= .venv/bin/pytest tests/ -v              # unit tests
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration  # integration tests

Install dependencies: uv sync --extra dev (pytest is in the dev extra; plain uv sync removes it)


Key Files

FilePurpose
src/comparer_mcp/server.pyMCP tool definitions and handlers
src/comparer_mcp/score_inputs.pyReference/target pair: schema and loading (inline or path)
src/comparer_mcp/engine.pyComparison orchestration (no MCP imports)
src/comparer_mcp/models.pyDataclasses: ComparisonResult, NoteDiff, etc.
src/comparer_mcp/comparison_view.pycompare_scores: detail levels, view_of(), filter folding, output schema (no MCP)
src/comparer_mcp/presenter.pycontent (unchanged JSON text) + structuredContent and output schemas for the Diff Viewer
src/comparer_mcp/diff_book.pyDiffBook: the scores of each compare_scores result under an opaque diff_id (no MCP)
src/comparer_mcp/result_schema.pyJSON Schema generated from the models.py dataclasses
src/comparer_mcp/part_matcher.pyPart matching logic (name, instrument, range)
src/comparer_mcp/note_aligner.pyEdit-distance note alignment
src/comparer_mcp/measure_comparator.pyMeasure-level structural comparison
src/comparer_mcp/report.pyHuman-readable comparison report (pure ComparisonResult -> str)
src/comparer_mcp/annotator.pyColored MusicXML diff export
src/comparer_mcp/utils.pyValidation, pitch names, duration formatting
docs/HANDOVER.mdStatus, remaining work, definition of done
docs/PLAN.mdImplementation plan and technology decisions
docs/requirements.mdFunctional/non-functional requirements
docs/architecture.mdFull vision, pipeline design, data model

Implemented Tools

ToolDescription
compare_scoresThe comparison tool: detail summary/changes/report/full, parts, measures, options; structuredContent + output_schema
compare_musicxmlDeprecated alias (detail="full"): full diff of two scores (inline or by path)
compare_musicxml_filesDeprecated alias (detail="full"): Full diff of two MusicXML file paths (read roots apply)
quick_similarityDeprecated alias (detail="summary"): Similarity score (0.0–1.0) + summary
list_changesDeprecated alias (detail="changes"): Filtered note-level diffs (part, measures)
generate_comparison_reportDeprecated alias (detail="report"): Human-readable version comparison report
export_annotated_musicxmlColored MusicXML diff export; paths for large results (return), feed them to render-mcp's musicxml_path
get_diff_scoresApp-only (Diff Viewer): both scores of a diff_id with the differences colored
export_diff_scoresApp-only (Diff Viewer): writes the annotated pair of a diff_id, returns paths
describe_scoreShared core tool: parts (IDs), key, time, range, measures — cheap, no music21
health_checkServer status and music21 version
list_capabilitiesServer metadata per conventions

MCP Apps Diff Viewer (ui://comparer/diff-viewer, server.DIFF_VIEWER): compare_scores, compare_musicxml, compare_musicxml_files and generate_comparison_report link it (_meta.ui.resourceUri) only when comparer_mcp/ui/assets/diff-viewer.html is packaged (hatch artifacts; gitignored build output). They return structuredContent (the full ComparisonResult, or {report, similarity_score}) and declare an output_schema; content stays byte-identical (tests/test_content_golden.py). Errors set isError and carry no structuredContent. When the HTML is packaged compare_scores adds a diff_id (the pair is kept in DiffBook); the app-only get_diff_scores and export_diff_scores take it, never a path.

Score references (UX Wave 2): every tool that took reference_xml / target_xml also takes reference_path / target_path, exactly one of each pair (score_inputs.py, built on sheet_music_mcp_core.references). Paths are confined to the read roots (SHEET_MUSIC_OUTPUT_ROOT, client roots, SHEET_MUSIC_INPUT_ROOTS) — compare_musicxml_files too, so tests that read files must set one of those to their tmp dir. Never open a score path yourself; use load_pair().

Measure ranges (UX Wave 3): options.measures and list_changes's measures are [start, end] inclusive measure numbers (schema sheet_music_mcp_core.measures.MEASURES_PROPERTY, validated with parse_range). Unlike the other servers they filter the differences, they do not cut the scores. measure_range is a deprecated alias in both places (params.aliased): equal values are accepted, different values are INVALID_PARAMETER, the old name alone logs one warning per process. Remove the aliases in the release after 0.3.0.


Environment

  • Core library: music21 — MusicXML parsing, score model, stream alignment
  • No system dependencies required
  • music21 import is slow (~2s first time) — this is expected

Hard Rules

  • Never pip install — use uv sync or uv add
  • engine.py must not import from mcp — keeps it unit-testable
  • All tool handlers must be async def
  • All errors → {"error": "...", "error_code": "..."} (codes: FILE_NOT_FOUND, FILE_TOO_LARGE, INVALID_INPUT, UNSUPPORTED_FORMAT, PROCESSING_FAILED, INVALID_PARAMETER)
  • Integration tests must be @pytest.mark.integration

MCP Server Startup Pattern

import asyncio
import mcp.server.stdio

async def _run():
    async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
        await app.run(read_stream, write_stream, app.create_initialization_options())

asyncio.run(_run())

run_server() does not exist in the installed MCP SDK — use the context manager above.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.