add_notes_to_clip_tool
Insert MIDI notes into a clip in Ableton Live by specifying track and clip indices, enabling precise control and automation of music production workflows.
Instructions
Add MIDI notes to a clip.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clip_index | Yes | ||
| notes | Yes | ||
| track_index | Yes |
Implementation Reference
- MCP_Server/server.py:99-107 (handler)The MCP tool handler and registration for 'add_notes_to_clip_tool'. It defines the tool schema via function signature and delegates to the underlying helper.@mcp.tool() def add_notes_to_clip_tool( ctx: Context, track_index: int, clip_index: int, notes: list[dict[str, int | float | bool]], ) -> str: """Add MIDI notes to a clip.""" return add_notes_to_clip(ctx, track_index, clip_index, notes)
- MCP_Server/tools/clip_tools.py:34-57 (helper)Server-side helper that forwards the command to the Ableton remote script.def add_notes_to_clip( ctx: Context, track_index: int, clip_index: int, notes: list[dict[str, int | float | bool]], ) -> str: """ Add MIDI notes to a clip. Parameters: - track_index: The index of the track containing the clip - clip_index: The index of the clip slot containing the clip - notes: List of note dictionaries, each with pitch, start_time, duration, velocity, and mute """ try: ableton = get_ableton_connection() result = ableton.send_command( "add_notes_to_clip", {"track_index": track_index, "clip_index": clip_index, "notes": notes}, ) return f"Added {len(notes)} notes to clip at track {track_index}, slot {clip_index}" except Exception as e: logger.error(f"Error adding notes to clip: {str(e)}") return f"Error adding notes to clip: {str(e)}"
- Remote script implementation that executes the logic using Ableton Live API (clip.set_notes).def add_notes_to_clip(self, track_index: int, clip_index: int, notes: list[dict[str, Any]]) -> dict[str, Any]: """Add MIDI notes to a clip""" try: clip_slot = self.get_clip_slot(track_index, clip_index) if not clip_slot.has_clip: raise Exception("No clip in slot") clip = clip_slot.clip # Validate and convert note data to Live's format live_notes = [] for note in notes: # Validate note data validate_note_data(note) pitch = note.get("pitch", 60) start_time = note.get("start_time", 0.0) duration = note.get("duration", 0.25) velocity = note.get("velocity", 100) mute = note.get("mute", False) live_notes.append((pitch, start_time, duration, velocity, mute)) # Add the notes clip.set_notes(tuple(live_notes)) result = {"note_count": len(notes)} return result except Exception as e: self.log_message("Error adding notes to clip: " + str(e)) raise