Add token-efficient tools: batch arrangement, guarded deletes, combined instrument creation, volume automation, sync check#110
Open
M4x28 wants to merge 1 commit into
Conversation
…ed instrument creation, volume automation, sync check - 11 new MCP tools (32 total): duplicate_to_arrangement_batch, create_instrument_track, get_tracks_overview, get_notes_from_clip, delete_clip, clear_clip_notes, delete_arrangement_clips, delete_track (two-phase confirm guardrail), set_track_volume, create_volume_fade, check_arrangement_sync. - Remove user_prompt parameter from all tools; compact JSON on read outputs. - Verified live on Ableton Live 12.4.2. Bump version to 1.2.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Token-efficient AbletonMCP (batch ops, guarded deletes, combined creation, volume + sync)
Summary
Reduces LLM token use and round trips, and adds capability, without changing the socket protocol style. Verified live on Ableton Live 12.4.2. On a full 3 minute arrangement the command count drops 91% (354 to 31), exact tokens drop 80% (33,521 to 6,804), and build time drops 89% (262s to 29s), while the optimized path also does volume automation and a sync check that the old path cannot.
What changed
Server exposes 32 tools (was 21). 11 new tools, plus a token diet on the existing ones.
New tools:
duplicate_to_arrangement_batch(track, clip, destination_time, count, spacing): place N copies in one call (spacing 0 = gapless).create_instrument_track(name, uri, clip_length, notes, clip_name): create track + name + load instrument + clip + notes in one call.get_tracks_overview(): compact list of all tracks (one call vs N verbose get_track_info).get_notes_from_clip(track, clip): read existing MIDI notes so edits are not guesses.delete_clip,clear_clip_notes,delete_arrangement_clips,delete_track: destructive ops with a two phase confirm guardrail (a call withoutconfirm=truereturns a preview and changes nothing).set_track_volume(track, value): static mixer volume.create_volume_fade(track, clip_index, from_value, to_value): volume automation fade on a Session clip (rides into the arrangement when duplicated). The Live API only allows automation on Session clips, so fades are authored there.check_arrangement_sync(bar_beats): compact grid alignment report (off_grid, overlaps, gaps counts plus only the problem clips).Token diet on existing tools:
user_promptparameter from all 21 original tools (42 sites). It forced the model to resend the whole prompt on every call.indent=2to separators).Guardrail
Deletes use a two phase confirm because an MCP call cannot pause for human input mid call. Without
confirm=truethe tool runs a dry run and returns exactly what would be removed; the human approves and re calls withconfirm=true.Breaking / behavior notes for the maintainer
user_promptdisables prompt based telemetry. The decorator degrades toNone, so nothing breaks, but if you want to keep prompt telemetry, make it an opt in env var instead.create_audio_clipneeds Live 12.0.5+, arrangement volume automation is authored on Session clips (documented in the tool).Files
MCP_Server/server.py: seePR_server.py.patchAbletonMCP_Remote_Script/__init__.py: seePR_remote_script.__init__.py.patchVerification
py_compile clean, FastMCP loads 32 tools,
user_promptabsent from every schema. All new endpoints tested live on a scratch track that was created and deleted. Full benchmark, charts and two audible demo sets in the attached report.Demo sets (download and open in Live 12)
These Ableton sets let a reviewer hear the output. They use only Live 12 factory devices (DS Kick/HH/Clap, Acid Bass, 303), so no external samples are needed.
These files live on the fork's
pr-assetsbranch and are not part of the code diff.Appendix A: Benchmark, round 2 (exact tokens, new endpoints, 3-minute track)
AbletonMCP Optimization, Round 2: exact tokens, new endpoints, 3-minute track
This round answers four requests: measure exact tokens (not an estimate), report a real end to end wall clock, reduce the cost of the sample creation phase, and add a long benchmark that builds a full 3 minute arrangement using two brand new endpoints. Everything below was run live against Ableton Live 12.4.2.
Method
Tokens are counted with a real BPE tokenizer (tiktoken
o200k_base) applied to the exact request and response strings of every call. This is an exact integer count, not a characters divided by four estimate. Claude's own tokenizer is not published for offline use, so a real tokenizer is the closest exact and reproducible measure.Wall clock is a single real timer around the whole run, from the first call to the last, reported as measured. It covers the connector plus Ableton execution. It does not include model inference time, so a real chat session would be slower on both versions, and more so on the original because it fires far more calls.
Two new endpoints (plus one that cuts phase 1)
create_volume_fadeinsert_stepAPI, fade 0.0 to 0.9 writtencheck_arrangement_syncset_track_volumecreate_instrument_trackThe Live API only allows volume automation on Session clips, so
create_volume_fadewrites the fade there and the arrangement inherits it when the clip is duplicated. That is why the intro and outro use dedicated 8 bar section clips.The connector fork now exposes 32 tools. All four endpoints were tested on a scratch track that was created and deleted, leaving the set unchanged.
Short benchmark (16 bar loop), exact numbers
Same acid track built twice: five instruments (kick, acid bass, hat, clap, acid melody) then a 16 bar arrangement. Identical music, so the only difference is the connector.
The sample creation phase now costs half as much and does more:
create_instrument_trackbuilds each instrument in one call and also names its clip. So the optimized version is cheaper and better organised at the same time, which was the request.Long benchmark: full 3 minute acid track at 140 BPM
The long test builds a real arrangement with intro, build, drop, break, climax and outro across 104 bars (about 3:12 at 140 BPM). The optimized run also adds a static mix, an intro fade in on the kick, an outro fade out on the bass, and a final synchronization check. The original run reproduces the same notes and arrangement with the old command style (one clip placement per call, prompt echoed on every call) and cannot do the automation or the check at all.
The arrangement phase is where the gap explodes: 327 individual placements on the original become 10 batch calls on the optimized version, and the placement cost drops from about 30,100 tokens to 602. The optimized total still includes roughly 4,557 tokens of volume automation work that the original simply cannot perform, so the optimized version does more and still costs 80 percent less.
The synchronization check confirmed the result: 328 arrangement clips, zero off grid, zero overlaps, in sync true. The four gaps it reports are the intentional silences of the break and the section entries, which the endpoint lists separately rather than treating as errors.
Deliverables
techno_acid_3min_140.alstechno_acid_optimized.als,techno_acid_original.alsbench2_long_phases.png,bench2_totals.pngshort_exact.json,long_exact.jsonNotes
The token figures use a real tokenizer, so treat them as exact for that tokenizer; Claude's absolute counts differ slightly but the relative reductions hold. The wall clock is the measured end to end time of each run. The four connector endpoints added this round are all verified live and shipped in the fork, which now carries 32 tools and activates on the next Claude Desktop restart.
Appendix B: First benchmark (16-bar build, original vs optimized)
AbletonMCP Benchmark - Techno Acid Track, End-to-End
Same track built twice through the same Ableton Live 12.4.2 + AbletonMCP socket, once with the original v1.2.0 command style, once with the optimized fork. Music is byte-identical between runs (
.als60,336 vs 60,351 B), so any difference is purely connector efficiency.1. Method
user_prompton every tool call and places arrangement clips one-by-one; optimized dropsuser_prompt, usesduplicate_to_arrangement_batch, and uses the compactget_tracks_overview.user_promptcounted for original,indent=2vs compact for reads), wall-clock seconds (real, measured over the socket).2. The track (identical in both runs)
130 BPM, A minor. Five parts, each its own MIDI track + device + 1 Session clip, then arranged.
query:Synths#DS%20Kickquery:Sounds#Bass:FileId_6970query:Synths#DS%20HHquery:Synths#DS%20Clapquery:Sounds#Bass:FileId_5239Structure: intro (kick+bass) → build (add hat+clap) → drop (add acid melody). 60 arrangement clips total.
3. Results
Per phase
Reading it:
duplicatecalls collapse to 5batchcalls (+1 view switch). Tokens −95%, time −89%.user_promptecho (~27 tok × 25 calls). Its wall-clock is instrument-load-bound, so the ~2 s difference is noise, not signal.4. Design decisions & changes (one by one)
user_promptfrom all 21 toolsNonecleanlyduplicate_to_arrangement_batch(count, spacing)spacing=0= gapless by clip lengthget_tracks_overviewget_session_info+ N verboseget_track_infoto orientindent=2→ separators) on 4 readsget_notes_from_clipdelete_clip/clear_clip_notes/delete_arrangement_clips/delete_track, two-phaseconfirmconfirm=truekeeps a human in the loopFull connector rationale and rollback: see
AbletonMCP_optimization_casestudy.md. Code diffs:server.py.patch,remote_script.__init__.py.patch.5. Deliverables (for qualitative A/B)
techno_acid_original.als- built via original workflowtechno_acid_optimized.als- built via optimized workflowBoth open in Ableton Live 12 (factory devices only, no external samples). They are sonically identical by construction - open either to judge the musical result; use the metrics above to judge the connector.
6. Caveats
Appendix C: Design decisions and rationale
Full design notes and rollback steps are in
AbletonMCP_optimization_casestudy.md(attached). Key points are summarised in the PR body above.