Skip to main content
Glama

add_midi_note

Insert a MIDI note into an existing MIDI item on a given track. Define pitch (middle C=60), start and length in seconds, velocity, and channel (9 for drums).

Instructions

Add a MIDI note to an existing MIDI item. pitch: MIDI note number 0–127 (60 = middle C, 69 = A4). start/length: seconds, relative to the item's start. channel: MIDI channel 0–15 (use 9 for drums).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
track_indexYes
item_indexYes
pitchYes
startYes
lengthYes
velocityNo
channelNo

Implementation Reference

  • The add_midi_note tool handler function, decorated with @mcp.tool(). It adds a MIDI note to an existing MIDI item at a given track_index, item_index with specified pitch (0-127), start/length (seconds relative to item start), velocity, and channel. Uses reapy's take.add_note() under the hood.
    @mcp.tool()
    def add_midi_note(
        track_index: int,
        item_index: int,
        pitch: int,
        start: float,
        length: float,
        velocity: int = 100,
        channel: int = 0,
    ) -> dict:
        """
        Add a MIDI note to an existing MIDI item.
        pitch: MIDI note number 0–127 (60 = middle C, 69 = A4).
        start/length: seconds, relative to the item's start.
        channel: MIDI channel 0–15 (use 9 for drums).
        """
        try:
            project = get_project()
            track = project.tracks[track_index]
            item = track.items[item_index]
            take = item.active_take
            if not take.is_midi:
                return {"success": False, "error": "Item is not a MIDI item"}
            take.add_note(
                start=start,
                end=start + length,
                pitch=pitch,
                velocity=velocity,
                channel=channel,
            )
            return {
                "success": True,
                "track_index": track_index,
                "item_index": item_index,
                "pitch": pitch,
                "start": start,
                "length": length,
                "velocity": velocity,
                "channel": channel,
            }
        except Exception as e:
            logger.error(f"add_midi_note failed: {e}")
            return {"success": False, "error": str(e)}
  • The registration call where register_tools from midi_tools is invoked with the mcp instance, which registers add_midi_note as an MCP tool.
    _reg_midi(mcp)
  • Import of register_tools from midi_tools module into the server, aliased as _reg_midi.
    from reaper_mcp.midi_tools import register_tools as _reg_midi
  • The get_project helper function used by add_midi_note to obtain the current REAPER project via reapy.
    def ensure_connected() -> None:
        global _connected
        if _connected:
            return
        try:
            reapy.connect()
            _connected = True
            logger.info("Connected to REAPER")
        except Exception as e:
            raise RuntimeError(
                f"Cannot connect to REAPER: {e}. "
                "Make sure REAPER is running and the distant API is enabled. "
                "To enable it: run the setup script (scripts/enable_reapy.py) or "
                "in REAPER go to Actions > Run ReaScript, then run: "
                "import reapy; reapy.config.enable_dist_api()"
            ) from e
    
    
    def get_project() -> reapy.Project:
  • The type-annotated function signature serves as the input schema for add_midi_note: track_index (int), item_index (int), pitch (int), start (float), length (float), velocity (int, default 100), channel (int, default 0).
    def add_midi_note(
        track_index: int,
        item_index: int,
        pitch: int,
        start: float,
        length: float,
        velocity: int = 100,
        channel: int = 0,
    ) -> dict:
Behavior3/5

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

No annotations provided, so the description must disclose behavior. It explains mutation and parameter meanings but does not cover error handling, bounds checking, or return values beyond parameter hints.

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

Conciseness5/5

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

Extremely concise: a single purpose sentence followed by bullet-like parameter explanations. Every sentence adds value, no redundancy.

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

Completeness3/5

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

Lacks explanation for required parameters (track_index, item_index) and does not describe return values or error conditions. For a tool with 7 parameters and no annotations, more context is needed for full completeness.

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?

With 0% schema description coverage, the description adds significant meaning: pitch as MIDI note number with mapping, start/length as seconds relative to item start, and channel hint for drums. However, track_index and item_index are not explained, and velocity is only hinted via default.

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?

The description clearly states 'Add a MIDI note to an existing MIDI item,' specifying the verb and resource. It also provides parameter details that distinguish it from siblings like create_midi_item.

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

Usage Guidelines3/5

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

No explicit guidance on when to use this tool versus alternatives like create_drum_pattern or when not to use it. The description implies usage for editing existing MIDI items but lacks context.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bonfire-audio/reaper-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server