comparer-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- comparer_mcp-0.1.0/.github/copilot-instructions.md +113 -0
- comparer_mcp-0.1.0/.gitignore +38 -0
- comparer_mcp-0.1.0/.python-version +1 -0
- comparer_mcp-0.1.0/CLAUDE.md +94 -0
- comparer_mcp-0.1.0/PKG-INFO +198 -0
- comparer_mcp-0.1.0/README.md +171 -0
- comparer_mcp-0.1.0/SETUP.md +131 -0
- comparer_mcp-0.1.0/TROUBLESHOOTING.md +12 -0
- comparer_mcp-0.1.0/docs/architecture.md +507 -0
- comparer_mcp-0.1.0/docs/requirements.md +108 -0
- comparer_mcp-0.1.0/examples/claude_desktop_config.json +9 -0
- comparer_mcp-0.1.0/examples/continue_config.json +10 -0
- comparer_mcp-0.1.0/examples/cursor_mcp.json +9 -0
- comparer_mcp-0.1.0/examples/windsurf_mcp.json +9 -0
- comparer_mcp-0.1.0/examples/zed_settings.json +12 -0
- comparer_mcp-0.1.0/install.sh +99 -0
- comparer_mcp-0.1.0/pyproject.toml +50 -0
- comparer_mcp-0.1.0/src/comparer_mcp/__init__.py +1 -0
- comparer_mcp-0.1.0/src/comparer_mcp/annotator.py +68 -0
- comparer_mcp-0.1.0/src/comparer_mcp/engine.py +501 -0
- comparer_mcp-0.1.0/src/comparer_mcp/measure_comparator.py +130 -0
- comparer_mcp-0.1.0/src/comparer_mcp/models.py +123 -0
- comparer_mcp-0.1.0/src/comparer_mcp/note_aligner.py +83 -0
- comparer_mcp-0.1.0/src/comparer_mcp/part_matcher.py +60 -0
- comparer_mcp-0.1.0/src/comparer_mcp/report.py +121 -0
- comparer_mcp-0.1.0/src/comparer_mcp/server.py +448 -0
- comparer_mcp-0.1.0/src/comparer_mcp/utils.py +84 -0
- comparer_mcp-0.1.0/tests/__init__.py +0 -0
- comparer_mcp-0.1.0/tests/test_annotator.py +123 -0
- comparer_mcp-0.1.0/tests/test_engine.py +470 -0
- comparer_mcp-0.1.0/tests/test_measure_comparator.py +172 -0
- comparer_mcp-0.1.0/tests/test_note_aligner.py +98 -0
- comparer_mcp-0.1.0/tests/test_part_matcher.py +89 -0
- comparer_mcp-0.1.0/tests/test_report.py +234 -0
- comparer_mcp-0.1.0/tests/test_server.py +424 -0
- comparer_mcp-0.1.0/tests/test_utils.py +126 -0
- comparer_mcp-0.1.0/uv.lock +1676 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# comparer-mcp — Copilot Instructions
|
|
2
|
+
|
|
3
|
+
## What This Server Does
|
|
4
|
+
|
|
5
|
+
Music-aware comparison of two MusicXML files. Provides structured, multi-level diffs
|
|
6
|
+
from global similarity score down to individual note differences. Primary use cases:
|
|
7
|
+
version/arrangement comparison, OMR quality evaluation, round-trip fidelity testing.
|
|
8
|
+
|
|
9
|
+
**Status:** Phase 4 (Advanced features) complete — all originally-scoped phases done. 134/134 tests
|
|
10
|
+
pass (127 unit + 7 integration). `server.py` exposes all 8 tools.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Before You Write Any Code
|
|
15
|
+
|
|
16
|
+
Read these documents in order:
|
|
17
|
+
1. **`docs/HANDOVER.md`** — current status, remaining work, definition of done
|
|
18
|
+
2. **`docs/PLAN.md`** — implementation plan and technology decisions
|
|
19
|
+
3. **`docs/requirements.md`** — functional and non-functional requirements
|
|
20
|
+
4. **`docs/architecture.md`** — full vision, 5-layer comparison pipeline, data model, similarity scoring
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Project Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
comparer-mcp/
|
|
28
|
+
├── pyproject.toml
|
|
29
|
+
├── .python-version # 3.11
|
|
30
|
+
├── src/comparer_mcp/
|
|
31
|
+
│ ├── server.py # MCP tool definitions, dispatches to engine
|
|
32
|
+
│ ├── engine.py # Comparison orchestration — NO mcp imports
|
|
33
|
+
│ ├── models.py # Dataclasses: ComparisonResult, NoteDiff, etc.
|
|
34
|
+
│ ├── part_matcher.py # Part matching (name, instrument, range)
|
|
35
|
+
│ ├── measure_comparator.py # Measure-level structural comparison
|
|
36
|
+
│ ├── note_aligner.py # Edit-distance note alignment
|
|
37
|
+
│ ├── report.py # Human-readable comparison report (pure ComparisonResult -> str)
|
|
38
|
+
│ ├── annotator.py # Colored MusicXML diff export
|
|
39
|
+
│ └── utils.py # Validation, pitch names, duration formatting
|
|
40
|
+
├── tests/
|
|
41
|
+
│ ├── test_engine.py # End-to-end comparison tests
|
|
42
|
+
│ ├── test_server.py # Tool schemas, error propagation
|
|
43
|
+
│ ├── test_part_matcher.py # Part matching edge cases
|
|
44
|
+
│ ├── test_note_aligner.py # Alignment algorithm tests
|
|
45
|
+
│ ├── test_report.py
|
|
46
|
+
│ ├── test_annotator.py
|
|
47
|
+
│ ├── test_utils.py
|
|
48
|
+
│ └── fixtures/ # MusicXML test files
|
|
49
|
+
└── docs/
|
|
50
|
+
├── HANDOVER.md
|
|
51
|
+
├── PLAN.md
|
|
52
|
+
├── requirements.md
|
|
53
|
+
└── architecture.md
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Implemented Tools
|
|
59
|
+
|
|
60
|
+
| Tool | Description |
|
|
61
|
+
|------|-------------|
|
|
62
|
+
| `compare_musicxml` | Full diff of two MusicXML strings → structured `ComparisonResult` JSON |
|
|
63
|
+
| `compare_musicxml_files` | Full diff of two MusicXML file paths → structured `ComparisonResult` JSON |
|
|
64
|
+
| `quick_similarity` | Similarity score (0.0–1.0) + summary statistics |
|
|
65
|
+
| `list_changes` | Filtered note-level diffs (by part, measure range) |
|
|
66
|
+
| `generate_comparison_report` | Human-readable version comparison report |
|
|
67
|
+
| `export_annotated_musicxml` | Colored MusicXML diff export (chain into render-mcp to visualize) |
|
|
68
|
+
| `health_check` | Server status and music21 version |
|
|
69
|
+
| `list_capabilities` | Server metadata per conventions |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Coding Standards
|
|
74
|
+
|
|
75
|
+
- **Package manager:** `uv` only — never `pip install`
|
|
76
|
+
- **`engine.py` must not import from `mcp`** — keeps it independently unit-testable
|
|
77
|
+
- **All tool handlers must be `async def`**
|
|
78
|
+
- **All error responses:** `{"error": "human description", "error_code": "SCREAMING_SNAKE"}`
|
|
79
|
+
- **Standard error codes:** `FILE_NOT_FOUND`, `INVALID_INPUT`, `UNSUPPORTED_FORMAT`, `PROCESSING_FAILED`, `INVALID_PARAMETER`
|
|
80
|
+
- **Integration tests** → `@pytest.mark.integration`
|
|
81
|
+
- **Python 3.11+**; `asyncio_mode = "auto"` in pytest config
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Running Tests
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Unit tests
|
|
89
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v
|
|
90
|
+
|
|
91
|
+
# Integration tests
|
|
92
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration
|
|
93
|
+
|
|
94
|
+
# Install dependencies
|
|
95
|
+
uv sync
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## MCP Server Startup Pattern
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
import asyncio
|
|
104
|
+
import mcp.server.stdio
|
|
105
|
+
|
|
106
|
+
async def _run():
|
|
107
|
+
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
|
|
108
|
+
await app.run(read_stream, write_stream, app.create_initialization_options())
|
|
109
|
+
|
|
110
|
+
asyncio.run(_run())
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`mcp.server.stdio.run_server()` does not exist — always use the context manager above.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Working development docs — tracked locally only (live in each server's docs/ folder)
|
|
2
|
+
HANDOVER.md
|
|
3
|
+
PLAN.md
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.pyc
|
|
8
|
+
*.pyo
|
|
9
|
+
*.pyd
|
|
10
|
+
*.egg-info/
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
.eggs/
|
|
14
|
+
|
|
15
|
+
# Virtual environments
|
|
16
|
+
.venv/
|
|
17
|
+
venv/
|
|
18
|
+
|
|
19
|
+
# Test caches
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
.ruff_cache/
|
|
23
|
+
|
|
24
|
+
# Test samples (large data — not committed)
|
|
25
|
+
test_samples/
|
|
26
|
+
|
|
27
|
+
# Editor / OS
|
|
28
|
+
.vscode/
|
|
29
|
+
.idea/
|
|
30
|
+
.DS_Store
|
|
31
|
+
Thumbs.db
|
|
32
|
+
|
|
33
|
+
# Environment overrides
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
|
|
37
|
+
# Snyk Security Extension - AI Rules (auto-generated)
|
|
38
|
+
.github/instructions/snyk_rules.instructions.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# comparer-mcp — Claude Code Instructions
|
|
2
|
+
|
|
3
|
+
## What This Server Does
|
|
4
|
+
|
|
5
|
+
Music-aware comparison of two MusicXML files. Provides structured, multi-level diffs
|
|
6
|
+
from global similarity score down to individual note differences. Primary use cases:
|
|
7
|
+
version/arrangement comparison, OMR quality evaluation, round-trip fidelity testing.
|
|
8
|
+
|
|
9
|
+
**Status:** Phase 4 (Advanced features) complete — all originally-scoped phases done. 134/134 tests
|
|
10
|
+
pass (127 unit + 7 integration). `server.py` exposes all 8 tools; engine.py/models.py/
|
|
11
|
+
part_matcher.py/note_aligner.py/measure_comparator.py/report.py/annotator.py/utils.py are all
|
|
12
|
+
implemented and independently usable.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Running Tests
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# From this directory
|
|
20
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v # unit tests
|
|
21
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration # integration tests
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Install dependencies: `uv sync`
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Key Files
|
|
29
|
+
|
|
30
|
+
| File | Purpose |
|
|
31
|
+
|------|---------|
|
|
32
|
+
| `src/comparer_mcp/server.py` | MCP tool definitions and handlers |
|
|
33
|
+
| `src/comparer_mcp/engine.py` | Comparison orchestration (no MCP imports) |
|
|
34
|
+
| `src/comparer_mcp/models.py` | Dataclasses: ComparisonResult, NoteDiff, etc. |
|
|
35
|
+
| `src/comparer_mcp/part_matcher.py` | Part matching logic (name, instrument, range) |
|
|
36
|
+
| `src/comparer_mcp/note_aligner.py` | Edit-distance note alignment |
|
|
37
|
+
| `src/comparer_mcp/measure_comparator.py` | Measure-level structural comparison |
|
|
38
|
+
| `src/comparer_mcp/report.py` | Human-readable comparison report (pure `ComparisonResult` -> str) |
|
|
39
|
+
| `src/comparer_mcp/annotator.py` | Colored MusicXML diff export |
|
|
40
|
+
| `src/comparer_mcp/utils.py` | Validation, pitch names, duration formatting |
|
|
41
|
+
| `docs/HANDOVER.md` | Status, remaining work, definition of done |
|
|
42
|
+
| `docs/PLAN.md` | Implementation plan and technology decisions |
|
|
43
|
+
| `docs/requirements.md` | Functional/non-functional requirements |
|
|
44
|
+
| `docs/architecture.md` | Full vision, pipeline design, data model |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Implemented Tools
|
|
49
|
+
|
|
50
|
+
| Tool | Description |
|
|
51
|
+
|------|-------------|
|
|
52
|
+
| `compare_musicxml` | Full diff of two MusicXML strings |
|
|
53
|
+
| `compare_musicxml_files` | Full diff of two MusicXML file paths |
|
|
54
|
+
| `quick_similarity` | Similarity score (0.0–1.0) + summary |
|
|
55
|
+
| `list_changes` | Filtered note-level diffs |
|
|
56
|
+
| `generate_comparison_report` | Human-readable version comparison report |
|
|
57
|
+
| `export_annotated_musicxml` | Colored MusicXML diff export (chain into render-mcp to visualize) |
|
|
58
|
+
| `health_check` | Server status and music21 version |
|
|
59
|
+
| `list_capabilities` | Server metadata per conventions |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Environment
|
|
64
|
+
|
|
65
|
+
- **Core library:** `music21` — MusicXML parsing, score model, stream alignment
|
|
66
|
+
- **No system dependencies** required
|
|
67
|
+
- **music21 import is slow** (~2s first time) — this is expected
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Hard Rules
|
|
72
|
+
|
|
73
|
+
- **Never `pip install`** — use `uv sync` or `uv add`
|
|
74
|
+
- **`engine.py` must not import from `mcp`** — keeps it unit-testable
|
|
75
|
+
- **All tool handlers must be `async def`**
|
|
76
|
+
- **All errors** → `{"error": "...", "error_code": "..."}` (codes: `FILE_NOT_FOUND`, `INVALID_INPUT`, `UNSUPPORTED_FORMAT`, `PROCESSING_FAILED`, `INVALID_PARAMETER`)
|
|
77
|
+
- **Integration tests** must be `@pytest.mark.integration`
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## MCP Server Startup Pattern
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import asyncio
|
|
85
|
+
import mcp.server.stdio
|
|
86
|
+
|
|
87
|
+
async def _run():
|
|
88
|
+
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
|
|
89
|
+
await app.run(read_stream, write_stream, app.create_initialization_options())
|
|
90
|
+
|
|
91
|
+
asyncio.run(_run())
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`run_server()` does not exist in the installed MCP SDK — use the context manager above.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: comparer-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for music-aware comparison of MusicXML files
|
|
5
|
+
Project-URL: Homepage, https://github.com/raulkivi/music-assistant
|
|
6
|
+
Project-URL: Repository, https://github.com/raulkivi/music-assistant
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/raulkivi/music-assistant/issues
|
|
8
|
+
Author-email: Raul Kivi <raulkivi@users.noreply.github.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: comparison,diff,mcp,music,musicxml
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: mcp<2.0.0,>=1.28.1
|
|
22
|
+
Requires-Dist: music21>=9.0.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# comparer-mcp
|
|
29
|
+
|
|
30
|
+
MCP server for music-aware comparison of MusicXML files. Provides structured, multi-level diffs
|
|
31
|
+
that report what changed between two scores — from global similarity down to individual notes.
|
|
32
|
+
|
|
33
|
+
## What it does
|
|
34
|
+
|
|
35
|
+
- **Version / arrangement comparison** — Compare different editions, arrangements, or simplifications of the same piece
|
|
36
|
+
- **OMR quality evaluation** — Compare `omr-mcp` output against a known-good reference
|
|
37
|
+
- **Round-trip fidelity** — Verify MusicXML → ABC → MusicXML through `musicxml-abc-mcp`
|
|
38
|
+
- **Regression testing** — Detect regressions when OMR models or conversion logic change
|
|
39
|
+
- **Score editing validation** — Confirm LLM-driven edits only changed intended elements
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
bash install.sh
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
See [SETUP.md](SETUP.md) for client config snippets (Claude Desktop, Cursor, Windsurf, Continue, Zed)
|
|
48
|
+
and [TROUBLESHOOTING.md](TROUBLESHOOTING.md) if something doesn't work.
|
|
49
|
+
|
|
50
|
+
## MCP Tools
|
|
51
|
+
|
|
52
|
+
| Tool | Description |
|
|
53
|
+
|------|-------------|
|
|
54
|
+
| `compare_musicxml` | Full diff of two MusicXML strings → structured `ComparisonResult` JSON |
|
|
55
|
+
| `compare_musicxml_files` | Full diff of two MusicXML file paths (`.musicxml`, `.xml`, or `.mxl`) → structured `ComparisonResult` JSON |
|
|
56
|
+
| `quick_similarity` | Similarity score (0.0–1.0) + summary statistics only, no per-note detail |
|
|
57
|
+
| `list_changes` | Note-level diffs (operation != `MATCH`), optionally filtered by part name and/or measure range |
|
|
58
|
+
| `generate_comparison_report` | Human-readable version comparison report — similarity headline, missing/extra parts and measures, key/time signature changes, note-level differences grouped by measure range (e.g. "transposed by 3 semitones in measures 17-24") |
|
|
59
|
+
| `export_annotated_musicxml` | MusicXML with per-note color annotations marking the diff; returns `reference_annotated_musicxml` + `target_annotated_musicxml`, chainable straight into render-mcp's `render_to_pdf`/`render_to_image` |
|
|
60
|
+
| `health_check` | Server status — verifies music21 is importable and runs a self-comparison smoke test |
|
|
61
|
+
| `list_capabilities` | Server metadata per project conventions |
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
// Compare two MusicXML strings
|
|
65
|
+
{
|
|
66
|
+
"tool": "compare_musicxml",
|
|
67
|
+
"arguments": {
|
|
68
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
69
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Compare two files
|
|
74
|
+
{
|
|
75
|
+
"tool": "compare_musicxml_files",
|
|
76
|
+
"arguments": {
|
|
77
|
+
"reference_path": "/path/to/reference.musicxml",
|
|
78
|
+
"target_path": "/path/to/omr_output.musicxml"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Quick similarity check
|
|
83
|
+
{
|
|
84
|
+
"tool": "quick_similarity",
|
|
85
|
+
"arguments": {
|
|
86
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
87
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// → {"similarity_score": 0.87, "summary": {...}}
|
|
91
|
+
|
|
92
|
+
// Filtered changes, e.g. "what changed in the Alto, measures 17-24?"
|
|
93
|
+
{
|
|
94
|
+
"tool": "list_changes",
|
|
95
|
+
"arguments": {
|
|
96
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
97
|
+
"target_xml": "<score-partwise>...</score-partwise>",
|
|
98
|
+
"part": "Alto",
|
|
99
|
+
"measure_range": [17, 24]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// → {"changes": [{"measure_number": 18, "operation": "PITCH_CHANGE", "part_name": "Alto", ...}], "count": 1}
|
|
103
|
+
|
|
104
|
+
// Human-readable report
|
|
105
|
+
{
|
|
106
|
+
"tool": "generate_comparison_report",
|
|
107
|
+
"arguments": {
|
|
108
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
109
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// → {"report": "Overall similarity: 87% (minor differences)\n...", "similarity_score": 0.87}
|
|
113
|
+
|
|
114
|
+
// Colored MusicXML diff export — chain straight into render-mcp to visualize
|
|
115
|
+
{
|
|
116
|
+
"tool": "export_annotated_musicxml",
|
|
117
|
+
"arguments": {
|
|
118
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
119
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// → {"reference_annotated_musicxml": "...", "target_annotated_musicxml": "...",
|
|
123
|
+
// "similarity_score": 0.87, "legend": {"PITCH_CHANGE": "#FF8800", ...}}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`compare_musicxml`, `compare_musicxml_files`, `generate_comparison_report`, and
|
|
127
|
+
`export_annotated_musicxml` all accept an optional `options` object:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"expand_repeats": false, // unfold repeats before comparing (default: false — opt-in)
|
|
132
|
+
"normalize_pitch": false, // transpose transposing instruments to concert/sounding pitch
|
|
133
|
+
"ignore_articulations": false, // exclude articulations from NoteInfo/diffs
|
|
134
|
+
"part_filter": ["Soprano"], // compare only named parts (case-insensitive)
|
|
135
|
+
"measure_range": [1, 32] // compare only measures 1-32, inclusive
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Using the engine directly
|
|
140
|
+
|
|
141
|
+
The comparison engine (`src/comparer_mcp/engine.py`) has no MCP dependency and is fully usable as
|
|
142
|
+
a plain Python library, independent of the MCP server:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
cd comparer-mcp
|
|
146
|
+
uv sync
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from comparer_mcp.engine import compare, compare_files
|
|
151
|
+
|
|
152
|
+
# Compare two MusicXML strings
|
|
153
|
+
result = compare(reference_xml, target_xml)
|
|
154
|
+
|
|
155
|
+
# Compare two files (.musicxml, .xml, or compressed .mxl)
|
|
156
|
+
result = compare_files("reference.musicxml", "omr_output.mxl")
|
|
157
|
+
|
|
158
|
+
print(result.similarity_score) # float, 0.0-1.0
|
|
159
|
+
print(result.summary) # ComparisonSummary: parts/measures/notes matched, missing, changed
|
|
160
|
+
print(result.part_diffs) # list[PartDiff] -> list[MeasureDiff] -> list[NoteDiff]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Errors are raised as `comparer_mcp.engine.ProcessingError` (e.g. for a missing file or invalid
|
|
164
|
+
MusicXML), carrying a `.error_code` attribute (`FILE_NOT_FOUND`, `INVALID_INPUT`, etc.) matching
|
|
165
|
+
the format the MCP tools return.
|
|
166
|
+
|
|
167
|
+
## Testing
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Unit tests
|
|
171
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m "not integration"
|
|
172
|
+
|
|
173
|
+
# Integration tests (real .mxl SATB fixtures shared with omr-mcp)
|
|
174
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration
|
|
175
|
+
|
|
176
|
+
# Install dependencies
|
|
177
|
+
uv sync
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Dependencies
|
|
181
|
+
|
|
182
|
+
- [music21](https://web.mit.edu/music21/) — MusicXML parsing, score object model, stream alignment
|
|
183
|
+
- [numpy](https://numpy.org/) — distance matrix for note alignment (transitive via music21)
|
|
184
|
+
- [mcp](https://github.com/modelcontextprotocol/python-sdk) — MCP protocol
|
|
185
|
+
|
|
186
|
+
## System requirements
|
|
187
|
+
|
|
188
|
+
- Python 3.11+
|
|
189
|
+
- No system libraries required
|
|
190
|
+
|
|
191
|
+
## Phase status
|
|
192
|
+
|
|
193
|
+
| Phase | Status |
|
|
194
|
+
|-------|--------|
|
|
195
|
+
| Phase 1 — Core comparison (MVP) | **Complete** — 45/45 tests passing (43 unit + 2 integration) |
|
|
196
|
+
| Phase 2 — Rich detail (key/time signature diffs, voice-aware alignment, articulations) | **Complete** — 67/67 tests passing (65 unit + 2 integration) |
|
|
197
|
+
| Phase 3 — MCP server & integration (`server.py`, all 6 tools, `install.sh`, `SETUP.md`, client config examples) | **Complete** — 94/94 tests passing (90 unit + 4 integration) |
|
|
198
|
+
| Phase 4 — Advanced features (`options` wiring, `generate_comparison_report`, `export_annotated_musicxml`) | **Complete** — 134/134 tests passing (127 unit + 7 integration) |
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# comparer-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for music-aware comparison of MusicXML files. Provides structured, multi-level diffs
|
|
4
|
+
that report what changed between two scores — from global similarity down to individual notes.
|
|
5
|
+
|
|
6
|
+
## What it does
|
|
7
|
+
|
|
8
|
+
- **Version / arrangement comparison** — Compare different editions, arrangements, or simplifications of the same piece
|
|
9
|
+
- **OMR quality evaluation** — Compare `omr-mcp` output against a known-good reference
|
|
10
|
+
- **Round-trip fidelity** — Verify MusicXML → ABC → MusicXML through `musicxml-abc-mcp`
|
|
11
|
+
- **Regression testing** — Detect regressions when OMR models or conversion logic change
|
|
12
|
+
- **Score editing validation** — Confirm LLM-driven edits only changed intended elements
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bash install.sh
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
See [SETUP.md](SETUP.md) for client config snippets (Claude Desktop, Cursor, Windsurf, Continue, Zed)
|
|
21
|
+
and [TROUBLESHOOTING.md](TROUBLESHOOTING.md) if something doesn't work.
|
|
22
|
+
|
|
23
|
+
## MCP Tools
|
|
24
|
+
|
|
25
|
+
| Tool | Description |
|
|
26
|
+
|------|-------------|
|
|
27
|
+
| `compare_musicxml` | Full diff of two MusicXML strings → structured `ComparisonResult` JSON |
|
|
28
|
+
| `compare_musicxml_files` | Full diff of two MusicXML file paths (`.musicxml`, `.xml`, or `.mxl`) → structured `ComparisonResult` JSON |
|
|
29
|
+
| `quick_similarity` | Similarity score (0.0–1.0) + summary statistics only, no per-note detail |
|
|
30
|
+
| `list_changes` | Note-level diffs (operation != `MATCH`), optionally filtered by part name and/or measure range |
|
|
31
|
+
| `generate_comparison_report` | Human-readable version comparison report — similarity headline, missing/extra parts and measures, key/time signature changes, note-level differences grouped by measure range (e.g. "transposed by 3 semitones in measures 17-24") |
|
|
32
|
+
| `export_annotated_musicxml` | MusicXML with per-note color annotations marking the diff; returns `reference_annotated_musicxml` + `target_annotated_musicxml`, chainable straight into render-mcp's `render_to_pdf`/`render_to_image` |
|
|
33
|
+
| `health_check` | Server status — verifies music21 is importable and runs a self-comparison smoke test |
|
|
34
|
+
| `list_capabilities` | Server metadata per project conventions |
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
// Compare two MusicXML strings
|
|
38
|
+
{
|
|
39
|
+
"tool": "compare_musicxml",
|
|
40
|
+
"arguments": {
|
|
41
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
42
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Compare two files
|
|
47
|
+
{
|
|
48
|
+
"tool": "compare_musicxml_files",
|
|
49
|
+
"arguments": {
|
|
50
|
+
"reference_path": "/path/to/reference.musicxml",
|
|
51
|
+
"target_path": "/path/to/omr_output.musicxml"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Quick similarity check
|
|
56
|
+
{
|
|
57
|
+
"tool": "quick_similarity",
|
|
58
|
+
"arguments": {
|
|
59
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
60
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// → {"similarity_score": 0.87, "summary": {...}}
|
|
64
|
+
|
|
65
|
+
// Filtered changes, e.g. "what changed in the Alto, measures 17-24?"
|
|
66
|
+
{
|
|
67
|
+
"tool": "list_changes",
|
|
68
|
+
"arguments": {
|
|
69
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
70
|
+
"target_xml": "<score-partwise>...</score-partwise>",
|
|
71
|
+
"part": "Alto",
|
|
72
|
+
"measure_range": [17, 24]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// → {"changes": [{"measure_number": 18, "operation": "PITCH_CHANGE", "part_name": "Alto", ...}], "count": 1}
|
|
76
|
+
|
|
77
|
+
// Human-readable report
|
|
78
|
+
{
|
|
79
|
+
"tool": "generate_comparison_report",
|
|
80
|
+
"arguments": {
|
|
81
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
82
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// → {"report": "Overall similarity: 87% (minor differences)\n...", "similarity_score": 0.87}
|
|
86
|
+
|
|
87
|
+
// Colored MusicXML diff export — chain straight into render-mcp to visualize
|
|
88
|
+
{
|
|
89
|
+
"tool": "export_annotated_musicxml",
|
|
90
|
+
"arguments": {
|
|
91
|
+
"reference_xml": "<score-partwise>...</score-partwise>",
|
|
92
|
+
"target_xml": "<score-partwise>...</score-partwise>"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// → {"reference_annotated_musicxml": "...", "target_annotated_musicxml": "...",
|
|
96
|
+
// "similarity_score": 0.87, "legend": {"PITCH_CHANGE": "#FF8800", ...}}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`compare_musicxml`, `compare_musicxml_files`, `generate_comparison_report`, and
|
|
100
|
+
`export_annotated_musicxml` all accept an optional `options` object:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"expand_repeats": false, // unfold repeats before comparing (default: false — opt-in)
|
|
105
|
+
"normalize_pitch": false, // transpose transposing instruments to concert/sounding pitch
|
|
106
|
+
"ignore_articulations": false, // exclude articulations from NoteInfo/diffs
|
|
107
|
+
"part_filter": ["Soprano"], // compare only named parts (case-insensitive)
|
|
108
|
+
"measure_range": [1, 32] // compare only measures 1-32, inclusive
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Using the engine directly
|
|
113
|
+
|
|
114
|
+
The comparison engine (`src/comparer_mcp/engine.py`) has no MCP dependency and is fully usable as
|
|
115
|
+
a plain Python library, independent of the MCP server:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
cd comparer-mcp
|
|
119
|
+
uv sync
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from comparer_mcp.engine import compare, compare_files
|
|
124
|
+
|
|
125
|
+
# Compare two MusicXML strings
|
|
126
|
+
result = compare(reference_xml, target_xml)
|
|
127
|
+
|
|
128
|
+
# Compare two files (.musicxml, .xml, or compressed .mxl)
|
|
129
|
+
result = compare_files("reference.musicxml", "omr_output.mxl")
|
|
130
|
+
|
|
131
|
+
print(result.similarity_score) # float, 0.0-1.0
|
|
132
|
+
print(result.summary) # ComparisonSummary: parts/measures/notes matched, missing, changed
|
|
133
|
+
print(result.part_diffs) # list[PartDiff] -> list[MeasureDiff] -> list[NoteDiff]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Errors are raised as `comparer_mcp.engine.ProcessingError` (e.g. for a missing file or invalid
|
|
137
|
+
MusicXML), carrying a `.error_code` attribute (`FILE_NOT_FOUND`, `INVALID_INPUT`, etc.) matching
|
|
138
|
+
the format the MCP tools return.
|
|
139
|
+
|
|
140
|
+
## Testing
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Unit tests
|
|
144
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m "not integration"
|
|
145
|
+
|
|
146
|
+
# Integration tests (real .mxl SATB fixtures shared with omr-mcp)
|
|
147
|
+
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration
|
|
148
|
+
|
|
149
|
+
# Install dependencies
|
|
150
|
+
uv sync
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Dependencies
|
|
154
|
+
|
|
155
|
+
- [music21](https://web.mit.edu/music21/) — MusicXML parsing, score object model, stream alignment
|
|
156
|
+
- [numpy](https://numpy.org/) — distance matrix for note alignment (transitive via music21)
|
|
157
|
+
- [mcp](https://github.com/modelcontextprotocol/python-sdk) — MCP protocol
|
|
158
|
+
|
|
159
|
+
## System requirements
|
|
160
|
+
|
|
161
|
+
- Python 3.11+
|
|
162
|
+
- No system libraries required
|
|
163
|
+
|
|
164
|
+
## Phase status
|
|
165
|
+
|
|
166
|
+
| Phase | Status |
|
|
167
|
+
|-------|--------|
|
|
168
|
+
| Phase 1 — Core comparison (MVP) | **Complete** — 45/45 tests passing (43 unit + 2 integration) |
|
|
169
|
+
| Phase 2 — Rich detail (key/time signature diffs, voice-aware alignment, articulations) | **Complete** — 67/67 tests passing (65 unit + 2 integration) |
|
|
170
|
+
| Phase 3 — MCP server & integration (`server.py`, all 6 tools, `install.sh`, `SETUP.md`, client config examples) | **Complete** — 94/94 tests passing (90 unit + 4 integration) |
|
|
171
|
+
| Phase 4 — Advanced features (`options` wiring, `generate_comparison_report`, `export_annotated_musicxml`) | **Complete** — 134/134 tests passing (127 unit + 7 integration) |
|