Skip to main content
Glama
MuseScore MCP Server

MuseScore MCP Server

by ghchen99

Collapse To Repeat

collapse_to_repeat

Collapse a run of repeated bars or phrases into one kept section with start/end repeat barlines and a play count, deleting duplicate copies while preserving the first phrase.

Instructions

Collapse a run of repeated bars or phrases into one played N times: keeps the first phrase_bars bars from start, deletes the rest of the run, and puts start/end repeat barlines with a play count around the kept bars (shown as e.g. '7x'). With phrase_bars=2, bars start..end must be a 2-bar phrase repeated (e.g. 28-35 becomes 28-29 x4). This changes every staff, so use it in a score that contains only the part being charted (make_part_score). It refuses when any staff's copies differ in anything but ghost notes and crashes on beat 1, unless force=True. Later measures are renumbered: collapse from the end of the score backwards. Needs MuseScore 4.6+.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "start": "<start>",
      "end": "<end>"
    },
    "name": "collapse_to_repeat"
  }
}

Input Schema

NameRequiredDescriptionDefault
endYesLast bar of the run (1-based, inclusive)
forceNoCollapse even if copies differ in more than ghost notes and crashes on beat 1 (those differences are lost)
startYesFirst bar of the run (1-based); the phrase starting here is kept
phrase_barsNoLength of the repeated phrase in bars (1, 2, 4...); the run must be a whole number of phrases

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: it discloses the deletion of bars, the barlines and play-count label that get inserted, the '7x' display form, the refusal condition on differing copies, that force=True loses those differences, measure renumbering side effects, and a MuseScore 4.6+ version requirement.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core action is front-loaded in the first clause, and the remaining sentences each add a distinct constraint (phrase alignment, staff-wide scope, refusal/force, renumbering, version). It is dense and reads as one long paragraph, but no sentence is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, no-annotation, no-output-schema mutation tool, the definition covers prerequisites, failure modes, ordering, and version compatibility well. The remaining gap is what the call returns or how success/failure is reported, which an agent would want before chaining calls.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds genuine meaning: 'keeps the first phrase_bars bars from start', the constraint that the run must be a whole number of phrases, and the worked example '28-35 becomes 28-29 x4'. It also clarifies that force discards only ghost-note/crash-on-beat-1 differences.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: collapse a run of repeated bars/phrases into one played N times, then enumerates the concrete edits (keep first phrase_bars bars, delete the rest, add repeat barlines with a play count). It never compares itself to adjacent siblings such as prepare_measure_repeat, apply_measure_repeats, or set_repeat_barlines, so an agent must infer the boundary from behavior alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states a real precondition ('use it in a score that contains only the part being charted (make_part_score)') and an operational ordering rule ('collapse from the end of the score backwards'), plus the refusal condition and the force escape hatch. What's missing is explicit routing against the other repeat-related tools, so the agent knows when this is the wrong choice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.