sheet-music-mcp / musicxml-abc-mcp
CLAUDE.md4 starsChanged 2 months agoMITView on GitHub
Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp Converts between MusicXML and ABC notation. ABC is compact and text-based — Claude can read and edit it directly in its context window, which is impractical with verbose MusicXML. Status: Phase 1 + UX Wave 1 + UX Wave 2 (score references) + UX Wave 3 (measures) complete. 313 unit tests pass (-m "not integration") + 6 integration. MCP Apps ABC Workbench server side done (structuredContent, output schemas, app-only get_abc); the page is built…
- Installs packages
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- comparer-mcp/CLAUDE.mdCLAUDE.md
- omr-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 74
Integration tests: must be @pytest.mark.integration and skipped in the default run
- Very specific: line 106
Score references (Wave 2): Read scores with sheet_music_mcp_core.references.load_score, never open a path yourself.
- Very specific: line 126
apply_abc_edit(C16): Never re-serialise the whole score: abc_edit._splice finds each <measure> byte span with expat (after defusedxml … - Distinctive: line 176
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
musicxml-abc-mcp — Claude Code Instructions
Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp
What This Server Does
Converts between MusicXML and ABC notation. ABC is compact and text-based — Claude can read and edit it directly in its context window, which is impractical with verbose MusicXML.
Status: Phase 1 + UX Wave 1 + UX Wave 2 (score references) + UX Wave 3 (measures) complete.
313 unit tests pass (-m "not integration") + 6 integration. MCP Apps ABC Workbench server side done (structuredContent, output schemas, app-only get_abc); the page is built (ui/apps/abc-workbench/: hunk review, live validate_abc, accept via abc_to_musicxml). apply_abc_edit (C16) merges an ABC bar edit back into the score.
Running Tests
# From this directory
VIRTUAL_ENV= .venv/bin/pytest tests/ -v # 313 unit tests (integration deselected)
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration # round-trip conversion testsInstall dependencies: uv sync --extra dev (note: --extra dev, not --group dev)
Key Files
| File | Purpose |
src/musicxml_abc_mcp/server.py | MCP tool definitions and handlers |
src/musicxml_abc_mcp/presenter.py | structuredContent + output schemas for the ABC Workbench tools |
src/musicxml_abc_mcp/abc_store.py | AbcStore: bounded, expiring abc_id handles to musicxml_to_abc results (no MCP imports) |
src/musicxml_abc_mcp/engine.py | Conversion pipeline + custom ABC serializer (no MCP imports) |
src/musicxml_abc_mcp/abc_edit.py | apply_abc_edit: splices edited bars into the score text (no MCP imports) |
src/musicxml_abc_mcp/abc_bars.py | Splits ABC at its bar lines, one tune per bar (no MCP imports) |
src/musicxml_abc_mcp/utils.py | Input validation helpers |
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 | Description |
musicxml_to_abc | MusicXML (musicxml text or musicxml_path, .mxl too) → ABC notation (all parts or one specific part; measures [start, end] for a range of printed bars) |
abc_to_musicxml | ABC notation → MusicXML; return auto (default) / path / inline — large scores come back as musicxml_path + score_summary (WRITES_FILE) |
apply_abc_edit | Replace bars measures [start, end] of one part with edited ABC; other parts, the header and all other bars stay byte-identical; warnings[] for lost dynamics, lyrics, articulations or changed bar lengths; return auto / path / inline (WRITES_FILE) |
validate_abc | Check ABC syntax, return errors/warnings |
list_capabilities | Server metadata and format support |
health_check | MusicXML → ABC → MusicXML round-trip self-test |
describe_score | Shared core tool: title, key, time, tempo, parts (P1…), ranges, measures, duration |
get_abc | App-only: the ABC of an earlier musicxml_to_abc by abc_id (omit for the latest); no paths |
Environment
- No system dependencies — pure Python (music21 + custom serializer)
- Backend: music21 (parsing + abc_to_musicxml) + custom ABC serializer for MusicXML → ABC
- MXL fixtures:
../omr-mcp/test_samples/pdmx_satb_samples/mxl/(10 SATB files)
Hard Rules
- Never
pip install— useuv sync --extra devoruv add engine.pymust not import frommcp— keeps it unit-testable- All tool handlers must be
async def - All errors →
{"error": "...", "error_code": "..."}(codes:INVALID_INPUT,INVALID_PARAMETER,PROCESSING_FAILED) - 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
- music21 9.x has NO ABC write support.
ConverterABC.registerOutputExtensions = ()meansmusic21.converter.toData(score, fmt='abc')fails silently or errors. The engine uses a custom ABC serializer that walks music21's note model directly. - ABC octave convention (v2.1): uppercase
C= C4 (middle C); lowercasec= C5.C D E F G A B= C4–B4;c d e f g a b= C5–B5;c' d'...= C6+;C, D,...= C3–B3. music21 parses ABC with the same convention, so the serializer must match it or ABC → MusicXML → ABC round-trips drift by an octave. - Round-trips are not lossless. Dynamics, complex articulations, and some ornaments have no
ABC equivalent. Surface these in the
warningsfield. - Score references (Wave 2). Read scores with
sheet_music_mcp_core.references.load_score, never open a path yourself; returnabc_to_musicxmlthroughdeliver_scoreso inline output stays byte-identical. Paths are confined toSHEET_MUSIC_OUTPUT_ROOT(default: working directory), the client's roots andSHEET_MUSIC_INPUT_ROOTS; files are written under<output root>/scores/. Tests must setSHEET_MUSIC_OUTPUT_ROOTtotmp_pathbefore a call that may write (any ABC giving over 8 KB of MusicXML inautomode). - Measure ranges (Wave 3).
musicxml_to_abc(measures=[start, end])cuts the MusicXML text with coreselect_measuresbefore music21 parses it (printed numbers, pickup 0); never filter music21 measures by.number. The cut score carries its tempo as a bare<sound tempo>, which music21 reads as a MetronomeMark with onlynumberSounding, soQ:falls back to it (_tempo_number). The serializer has no pickup or bar-number logic, so a cut starting at bar 3 needs no special case. - MCP Apps ABC Workbench.
musicxml_to_abcandabc_to_musicxmllinkui://abc/workbenchonly whenmusicxml_abc_mcp/ui/assets/abc-workbench.htmlis packaged (gitignored, shipped via hatchartifacts); tests use thepackaged_uifixture inconftest.py.contentis pinned bytests/golden/abc_content.json(ABC_GOLDEN_UPDATE=1re-records it; music21's random part ids are masked).structuredContentnever holds a MusicXML score:abc_to_musicxmlreports{warnings, delivery, musicxml_bytes}. Everymusicxml_to_abcsuccess stores its result inserver.abc_storeunder a freshabc_id(only instructuredContent, nevercontent); the app-onlyget_abcreturns it. Tests get a fresh store from an autouse fixture. apply_abc_edit(C16). Never re-serialise the whole score:abc_edit._splicefinds each<measure>byte span withexpat(after defusedxml parsed the score) and swaps only the edited bars, so other parts stay byte-identical. music21 re-bars ABC by itsM:meter (overfull bars split, short bars merged), soabc_bars.split_barscuts the ABC at its own bar lines and each bar is converted alone underM:64/4(a much longer meter such as 1024/4 makes music21 take seconds per bar). Edited bars keep the original shell (<print>, leading<attributes>, bar lines, tempo); durations are rescaled to the part's divisions, and finer divisions are restored on the next untouched bar. Warnings use the structured contract (code,severity,message,measure,part), unlike the stringwarningsof the older tools.- Naturals under a key signature are lost by
musicxml_to_abc. The serializer writes no=, so B natural in E-flat major exports asBand comes back as B flat (seen on a PDMX SATB sample). This also affects an unchangedmusicxml_to_abc→apply_abc_editround trip. Open bug. X:header required. music21's ABC parser requires the tune-number header. It adds it automatically on output but may fail to parse input that lacks it.
ABC Quick Reference
Minimal valid ABC:
X:1
T:Test Tune
M:4/4
L:1/8
K:G
GABG DEFD | GABc d4 |]Standard: https://abcnotation.com/wiki/abc:standard:v2.1
Claude Desktop Config
{
"mcpServers": {
"musicxml-abc": {
"command": "uv",
"args": ["--directory", "/path/to/musicxml-abc-mcp", "run", "musicxml-abc-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.

