sheet-music-mcp / omr-mcp
CLAUDE.md4 starsChanged 2 months agoMITView on GitHub
Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp Converts sheet music images (PNG/JPEG) to MusicXML. Two selectable OMR backends: oemer (default, in-process) and audiveris (opt-in via engine="audiveris", subprocess). Entry point of the choir pipeline — all other servers consume MusicXML produced here. Status: Phases 1–4 code complete, including the Audiveris backend option (shipped 2026-08-16). UX Wave 2 (score references) done. 344 unit tests pass (+48 skipped). MCP Apps Recognition Review server side done (structuredContent, app-only get_source_preview, staff_systems_estimate = staves per system, checked…
- Installs packages
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- comparer-mcp/CLAUDE.mdCLAUDE.md
- musicxml-abc-mcp/CLAUDE.mdCLAUDE.md
- pitch-mcp/CLAUDE.mdCLAUDE.md
- render-mcp/CLAUDE.mdCLAUDE.md
- synth-mcp/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
The file
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are 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.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 80
Integration tests: must be @pytest.mark.integration and skipped in the default run
- Very specific: line 130
Test images for it are generated with Pillow in tests/test_resolution_check.py.
- Very specific: line 153
The staff estimate counts staves per system, not per page: Test pages must join a system's staves with a vertical system line …
- Distinctive: line 178
When you finish work or reach a milestone, update:
≈ “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.
Files
omr-mcp — Claude Code Instructions
Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp
What This Server Does
Converts sheet music images (PNG/JPEG) to MusicXML. Two selectable OMR backends: oemer (default,
in-process) and audiveris (opt-in via engine="audiveris", subprocess). Entry point of the choir
pipeline — all other servers consume MusicXML produced here.
Status: Phases 1–4 code complete, including the Audiveris backend option (shipped 2026-08-16).
UX Wave 2 (score references) done. 344 unit tests pass (+48 skipped). MCP Apps Recognition Review server side done (structuredContent, app-only get_source_preview, staff_systems_estimate = staves per system, checked on 60 real sample pages); the Recognition Review page is built (ui/apps/recognition-review/). Integration tests run
against real oemer for the first time (2026-08-15): fixing a 100%-blocking API bug plus pinning
onnxruntime and opencv-python-headless took the suite from 0/41 to 20/41 passing. oemer's default output is not usable for SATB scores — it
reads multi-staff systems sequentially instead of simultaneously, so a 4-voice choir score comes
out as one part with the clef alternating back and forth instead of 4 parts sounding together;
root-caused 2026-08-16 as an architectural limitation (build_system.py hard-asserts at most 2
simultaneous staff tracks). Fixed via engine="audiveris", validated against real Audiveris on
both of oemer's failure modes (crash case + silent-flattening case) — correctly recovers separate
SATB parts in both. Not yet the default engine (see docs/HANDOVER.md "Audiveris engine option"
for why). 2/4 CPDL images also hit further oemer-internal crashes on this specific input data —
both root-caused 2026-08-16 (one is the SATB bug itself manifesting as a hard crash; see
docs/HANDOVER.md for the full writeup).
Running Tests
# From this directory
VIRTUAL_ENV= .venv/bin/pytest tests/ -v # 344 unit tests (+48 skipped; fast; all subprocess/network calls mocked)
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration # invokes real oemer (~3–5 min/page)Install dependencies: uv sync
Key Files
| File | Purpose |
src/omr_mcp/server.py | MCP tool definitions and handlers |
src/omr_mcp/omr_engine.py | oemer + Audiveris wrappers, _ENGINE_RUNNERS dispatch table (no MCP imports) |
src/omr_mcp/presenter.py | structuredContent and output schemas for the Recognition Review |
src/omr_mcp/previews.py | Source-preview JPEG and the job table (score + previews) |
src/omr_mcp/recognition_warnings.py | Structured warnings[] (LOW_RESOLUTION, PARTS_FEWER_THAN_STAVES at severity info) |
src/omr_mcp/staff_estimate.py | Staves per system from the image (staff_systems_estimate); evidence in docs/staff-estimate-evidence.md |
src/omr_mcp/utils.py | Image validation, base64 helpers |
tests/ | Unit tests per module (test_omr.py, test_recognition_review.py, test_source_preview.py, test_staff_estimate.py, test_recognition_warnings.py, ...); integration in test_integration.py, test_satb_samples.py, test_staff_estimate_samples.py |
test_samples/pdmx_satb_samples/ | 10 SATB PNG + MXL ground-truth fixtures |
docs/HANDOVER.md | Status, remaining work, definition of done |
docs/PLAN.md | Architecture decisions and rationale |
docs/requirements.md | Functional/non-functional requirements |
docs/architecture.md | Component diagram and data-flow |
Implemented Tools
| Tool | Input | Output |
recognize_sheet | Image path or base64; optional engine ("oemer"|"audiveris"), return ("auto"|"path"|"inline") | MusicXML string + metadata; large results (auto) as musicxml_path + score_summary |
recognize_sheet_to_file | Image path; optional engine | MusicXML file path + metadata + score_summary |
recognize_sheets | List of image paths/base64; optional engine, return | Single merged MusicXML (multi-page); large results as musicxml_path + score_summary |
get_recognized_score | job_id (app-only) | The MusicXML of an earlier recognition |
get_source_preview | job_id, optional page, offset, length (app-only) | Chunk of a downscaled JPEG of an input page, by opaque id |
list_capabilities | — | Server capabilities incl. per-engine availability |
list_supported_formats | — | Deprecated alias for list_capabilities |
health_check | — | Runtime dependency status incl. oemer/model cache/Audiveris |
Hard Rules
- Never
pip install— useuv syncoruv add omr_engine.pymust not import frommcp— keeps it unit-testable- All tool handlers must be
async def - All errors →
{"error": "...", "error_code": "..."}(codes:FILE_NOT_FOUND,UNSUPPORTED_FORMAT,FILE_TOO_LARGE,INVALID_INPUT,PROCESSING_FAILED,INVALID_PARAMETER) - Integration tests must be
@pytest.mark.integrationand skipped in the default run
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.
Known Gotchas
- oemer downloads ~100 MB on first run and takes ~10 min. Subsequent runs use cache.
- oemer output varies slightly between runs — never assert byte-identical XML; parse and compare structure instead.
- MusicXML from oemer may not validate against strict schema — check for parseable content and presence of parts/measures.
- The full PDMX dataset (14 GB) lives in
test_samples/pdmx_full/— never load or iterate it in tests; usepdmx_satb_samples/only. .python-version(llm311) is a pyenv-virtualenv nameuvdoesn't understand —uv syncsilently falls back to whateverpython3is onPATHinstead of erroring. Always check.venv/bin/python --versionafteruv venv/uv sync; useuv venv --python 3.11if it's wrong.omr_engine.pyforcesCUDA_VISIBLE_DEVICES=""at import time. On this dev host, onnxruntime's CUDA execution provider hard-aborts the process instead of raising a catchable Python exception. Real GPU inference would need a matched onnxruntime-gpu/CUDA driver pair.opencv-python-headlessis pinned inpyproject.toml, andonnxruntime-gpuis excluded via[tool.uv] override-dependencies— oemer's own packaging leaves both unpinned; opencv 5.x changedcv2.HoughLinesP's return shape.onnxruntimeis current (>=1.30): its stricter ConvTranspose validation is handled byonnx_compat.fix_negative_convtranspose_pads(), which_run_oemer()applies to the cachedunet_bigmodel before every recognition. Full details indocs/HANDOVER.md.engine="audiveris"downloads ~80 MB on first use (self-contained, bundles its own JRE) into~/.cache/omr-mcp/audiveris/, extracted viadpkg-deb -x— no root, no systemapt/dpkg -i. Requiresdpkg-deb(present on virtually all Debian/Ubuntu systems).- Audiveris needs genuinely 300+ DPI input — unlike oemer, which normalizes every input to a
fixed internal pixel budget and is DPI-insensitive in practice. Audiveris explicitly rejects
lower-resolution sheets rather than degrading gracefully.
utils.check_resolution()pre-checks pixel size (not DPI metadata) forengine="audiveris"only: < 1500 px long side fails withINVALID_INPUTbefore Audiveris starts; 1500–2499 px runs with a top-levelwarningsentry. Test images for it are generated with Pillow intests/test_resolution_check.py. - Audiveris can exit 0 while producing no output (e.g. it rejected every sheet for low
resolution) —
_run_audiveris()detects failure by checking for the expected.mxloutput file's existence, not the subprocess exit code. - Large recognition results come back as a file (UX Wave 2).
recognize_sheetandrecognize_sheetsdefault toreturn="auto": aboveSHEET_MUSIC_INLINE_MAX_BYTES(8192 bytes) the score is written to<SHEET_MUSIC_OUTPUT_ROOT>/scores/recognized-<timestamp>.musicxmland the JSON holdsmusicxml_path+score_summaryinstead ofmusicxml. Tests that need the text passreturn="inline"or keep the mocked score small; setSHEET_MUSIC_OUTPUT_ROOTtotmp_pathso nothing is written to the working directory. Both tools are thereforeWRITES_FILE_DOWNLOADS. Delivery usessheet_music_mcp_core.references.deliver_score;confine_output_pathinutils.pyis a re-export of the core one. - MCP Apps Recognition Review.
recognize_sheet/recognize_sheetslinkui://omr/recognition-reviewonly whenomr_mcp/ui/assets/recognition-review.htmlis packaged (gitignored, shipped via hatchartifacts); tests use thepackaged_uiand in-memory artifact store fixtures inconftest.py.contentis pinned bytests/golden/omr_content.json(OMR_GOLDEN_UPDATE=1re-records it).structuredContentnever holds the MusicXML (the app callsget_recognized_score). The job, the preview files andstaff_systems_estimateare made only for clients that advertise MCP Apps; a call withctx=Nonecounts as one that does not, so tests that want the app pass a ctx (see_ctxintests/test_recognition_review.py).get_*app tools never take a path; every input image is re-encoded into the output root first. The page (ui/apps/recognition-review/) readswarnings[]andmetadata.staff_systems_estimate, callsrecognize_sheetagain withenginefrom the tool input it received, and shows page 1 only (multi-page is later).pytestruns withasyncio_mode = "auto". - The staff estimate counts staves per system, not per page. Test pages must join a system's
staves with a vertical system line (
_page_image(staves=4)intests/test_recognition_review.pydoes); unjoined staves count as one-staff systems.tests/test_staff_estimate_samples.py(integration) checks it on the real pages; from a worktree setOMR_TEST_SAMPLESto the main checkout'somr-mcp/test_samples.
Claude Desktop Config
{
"mcpServers": {
"omr": {
"command": "uv",
"args": ["--directory", "/path/to/omr-mcp", "run", "omr-mcp"]
}
}
}Document Update Policy
When you finish work or reach a milestone, update:
docs/HANDOVER.md— check off done items, add new gotchasdocs/PLAN.md— check off phase items, note changed decisionsdocs/requirements.md— update if behaviour changeddocs/architecture.md— update if implementation changed
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
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.

