sheet-music-mcp / render-mcp
CLAUDE.md4 starsChanged 2 months agoMITView on GitHub
Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp Renders MusicXML scores to PDF (for printing) or PNG (for display in web/mobile apps). Uses Verovio (in-process) + cairosvg + pypdf. No MuseScore CLI required. Status: Phase 1 + UX Waves 1–3 complete; MCP Apps pages built: Score Viewer (SVG and PDF download, part filter and highlight; app-only render_page_svg, get_pdf, read_pdf_chunk) and Setup Doctor. 284 unit tests (default run) + 13 integration. tests/test_packaging.py (integration) needs the UI built first: cd ../ui && npm ci…
- 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
- omr-mcp/CLAUDE.mdCLAUDE.md
- pitch-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
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
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
- Very specific: line 90
Integration tests: must be @pytest.mark.integration and skipped in the default run
- Distinctive: line 118
MuseScore not installed: Don't check for or attempt to call any MuseScore CLI command.
- Distinctive: line 161
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
render-mcp — Claude Code Instructions
Last changed: 2026-11-26 · Source: https://github.com/raulkivi/sheet-music-mcp
What This Server Does
Renders MusicXML scores to PDF (for printing) or PNG (for display in web/mobile apps). Uses Verovio (in-process) + cairosvg + pypdf. No MuseScore CLI required.
Status: Phase 1 + UX Waves 1–3 complete; MCP Apps pages built: Score Viewer (SVG and PDF
download, part filter and highlight; app-only render_page_svg, get_pdf, read_pdf_chunk) and
Setup Doctor. 284 unit tests (default run) + 13 integration.
Running Tests
# From this directory
VIRTUAL_ENV= .venv/bin/pytest tests/ -v # 284 unit tests (integration deselected)
VIRTUAL_ENV= .venv/bin/pytest tests/ -v -m integration # Verovio runs in-process, always fasttests/test_packaging.py (integration) needs the UI built first:
cd ../ui && npm ci && npm run build && npm run copy-assets.
Install dependencies: uv sync
Key Files
| File | Purpose |
src/render_mcp/server.py | MCP tool definitions and handlers, Score Viewer registry |
src/render_mcp/presenter.py | Engine result → content + structuredContent; output schemas |
src/render_mcp/ui/assets/score-viewer.html, setup-doctor.html | Built by ui/ (npm run copy-assets), gitignored |
src/render_mcp/health.py | Health checks mapped to the shared report (core health) |
src/render_mcp/engine.py | Verovio + cairosvg rendering pipeline (no MCP imports) |
src/render_mcp/utils.py | MusicXML validation, path 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 |
render_to_pdf | MusicXML → multi-page PDF at caller-specified path |
render_to_image | MusicXML → PNG or SVG, single page, configurable DPI |
list_capabilities | Server metadata, active backend, format support |
health_check | Runtime dependency check; structuredContent health report, linked to ui://render/setup-doctor |
describe_score | Shared (core) tool: parts with IDs, key, time, tempo, measures, duration — no rendering |
render_page_svg | App-only (_meta.ui.visibility: ["app"]): one page of inline MusicXML as SVG for the Score Viewer when the host blocks WebAssembly; listed only for MCP Apps clients |
get_pdf / read_pdf_chunk | App-only: the Score Viewer's PDF download. get_pdf(musicxml) writes a PDF under the output root and returns an opaque pdf_id; read_pdf_chunk(pdf_id, offset, length) returns base64 chunks (core artifacts). No paths in or out |
render_to_pdf and render_to_image link ui://render/score-viewer (_meta.ui.resourceUri)
when the HTML is packaged, declare an output_schema and return structuredContent; their
content is unchanged (tests/test_content_golden.py).
Both render tools take the score as musicxml (inline) or musicxml_path (.musicxml, .xml,
.mxl; exactly one). Paths are read via sheet_music_mcp_core.references.load_score(), confined
to the output root, the client's roots and SHEET_MUSIC_INPUT_ROOTS (UX Wave 2, score references).
Both also take an optional measures: [start, end] (printed bar numbers, inclusive; UX Wave 3):
the engine cuts the score with sheet_music_mcp_core.measures.select_measures() before backend
dispatch, so MuseScore and Verovio render the same bars.
Environment
- Backend: Verovio (MusicXML → SVG, in-process Python) + cairosvg (SVG → PNG/PDF) + pypdf (merge pages)
- System dep:
libcairo.so.2— installed system-wide on Ubuntu, no sudo needed - No MuseScore CLI — do not attempt to invoke
mscore4/musescore4 - MXL fixtures:
../omr-mcp/test_samples/pdmx_satb_samples/mxl/(10 SATB files)
Hard Rules
- Never
pip install— useuv sync --extra dev(pytest is adevextra) oruv add - Never open a score path yourself — use
references.load_score(); output paths go throughconfine_output_path(re-exported fromsheet_music_mcp_core.pathsinutils.py) engine.pymust not import frommcp— keeps it unit-testable- All tool handlers must be
async def - All errors →
{"error": "...", "error_code": "..."}(codes:INVALID_INPUT,PROCESSING_FAILED,INVALID_PARAMETER,FILE_NOT_FOUND) - 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
- cairosvg DPI with Verovio SVGs. Verovio emits SVGs with fixed pixel dimensions — the
dpikwarg incairosvg.svg2png(dpi=...)has no effect. Usescale=dpi/96.0instead (96 px/in is the CSS reference density). - Multi-page PDF: each SVG page is converted to a single-page PDF via cairosvg, then merged with pypdf. Single-page scores skip the merge step.
- MuseScore not installed. Don't check for or attempt to call any MuseScore CLI command.
- Schema
oneOf, notrequired. The render tools have norequiredlist;musicxml/musicxml_pathare anexactly_onepair. A directcall_toolwith neither now returnsINVALID_PARAMETER(fromload_score) rather thanINVALID_INPUT. - Measure ranges are cut in the engine, not the backends.
render_to_pdf/render_to_imageapplyselect_measuresbefore dispatch; keep the_render_*functions unaware of ranges. The server passesmeasuresonly when given, so default engine calls keep their old signature.pagecounts pages of the cut score. Bad ranges areINVALID_PARAMETERwith ahint("This score has measures A–B."); the render handlers useprocessing_error_contentso the hint survives. call_toolvscall_tool_result. The server wirescall_tool_result();call_tool()returns itscontentonly (older tests index it as a list). Render errors areisError.- Tests never see a local UI build.
tests/conftest.pyswapsserver.ui_registryfor in-memory assets; thepackaged_uifixture gives the linked case. - Layout parity.
engine.page_layout()mirrorsui/packages/kit/src/score/paging.tslayoutFor()(JS rounding); both are checked againstui/packages/kit/src/score/layout-cases.json. - Verovio reads almost anything. Validate with
validate_musicxml()before the engine. - Verovio's resource path is per thread.
render_page_svgrenders in a worker thread (asyncio.to_thread, one at a time behind a lock);engine._verovio_toolkit()sets the resource path itself, or a toolkit made off the importing thread finds no fonts. - Integration tests need the omr-mcp samples. They read
../omr-mcp/test_samples/pdmx_satb_samples/mxl/; without that folder they fail with "Fixture dir not found".
Claude Desktop Config
{
"mcpServers": {
"render": {
"command": "uv",
"args": ["--directory", "/path/to/render-mcp", "run", "render-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.

