Skip to main content
Glama
libsonare-mcp

libsonare-mcp

Official
by libraz

Write notes to a MIDI file

midi_write
Destructive

Writes inline JSON note tracks, including tempo and time-signature maps, or exports a project's tracks to a Standard MIDI File (.mid) for playback or another program.

Instructions

Writes inline tracks (with an optional tempo map and time signatures), or a project file's tracks and tempo map, as a Standard MIDI File. Use it to turn notes you composed as JSON into a playable .mid file, or to export a project for another program. Not for changing the music (use midi_edit) and not for generating music (use midi_compose); to hear it, put the .mid on a project track with project_edit addMidiClip and call project_render. Example: {"source": [{"name": "lead", "program": 80, "notes": [{"pitch": 60, "start_ppq": 0, "length_ppq": 1}]}], "output": "lead.mid"}.

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": {
      "source": "<source>"
    },
    "name": "midi_write"
  }
}

Input Schema

NameRequiredDescriptionDefault
detailNo'concise' returns the summary and the most useful fields; 'full' returns all.concise
outputNoOutput .mid path. Omit to auto-name a file in the output directory.
sourceYesWhat to write: inline tracks, or a project file (its tracks and tempo map are exported). A .mid/.midi file path, a project file path (.sonare.json) or inline tracks [{name?, program?, channel?, is_drum?, notes: [{pitch, start_ppq, length_ppq, velocity}]}]. Track ids of a file are the core's (1, 2, ...); inline tracks count from 1.
dry_runNoReport what would be written, with the planned path, only.
overwriteNoReplace an existing file at 'output' (default false).
tempo_segmentsNoTempo map for inline tracks (default: constant 120 BPM). Not for a project source, which carries its own.
time_signaturesNoTime signatures for inline tracks (default: 4/4). Not for a project source.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, so the write risk is signposted; the description adds real value by clarifying that output is a file on disk, that a project source carries its own tempo map, and that rendering is a separate step. It does not spell out the overwrite/refuse-to-clobber behavior that the schema exposes via 'overwrite', which keeps it from a 5.

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?

Purpose is front-loaded in the first sentence, alternatives follow, and the example lands last — a sensible order with no filler clauses. It is dense and packs the exclusions, workflow, and example into one paragraph, which is efficient but slightly heavy to scan.

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 7-parameter, high-coverage write tool with no output schema, the description covers purpose, modes, exclusions, and the downstream render path adequately. It leaves the return payload (shaped by the 'detail' enum) and dry-run reporting to the schema, which is a minor but real gap for an agent planning a call.

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

Parameters3/5

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

Schema description coverage is 100%, so all seven parameters — including source union, tempo_segments, time_signatures, dry_run and overwrite — are already documented in structured form. The description adds only an illustrative example of the inline-track shape, which reinforces but does not extend the schema, making baseline 3 correct.

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

Purpose5/5

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

States a specific verb and resource ('Writes ... as a Standard MIDI File') and enumerates the two input modes (inline tracks vs. a project file's tracks and tempo map). It explicitly distinguishes itself from midi_edit and midi_compose, so an agent can place it in the toolset without opening any schema.

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

Usage Guidelines5/5

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

Gives concrete when-to-use cases ('turn notes you composed as JSON into a playable .mid file', 'export a project for another program') and explicit when-not-to-use with named alternatives (midi_edit for changing music, midi_compose for generating it). It even closes the loop on the follow-up workflow via project_edit addMidiClip and project_render.

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