create_clip
Create a new MIDI clip in Ableton Live by specifying track and clip slot indices, with customizable length in beats for music production workflows.
Instructions
Create a new MIDI clip in the specified track and clip slot.
Parameters:
track_index: The index of the track to create the clip in
clip_index: The index of the clip slot to create the clip in
length: The length of the clip in beats (default: 4.0)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| track_index | Yes | ||
| clip_index | Yes | ||
| length | No |
Implementation Reference
- MCP_Server/server.py:322-342 (handler)Primary MCP tool handler for 'create_clip'. Decorated with @mcp.tool() for automatic registration and schema inference from signature/docstring. Proxies parameters to the Ableton remote script via socket command.@mcp.tool() def create_clip(ctx: Context, track_index: int, clip_index: int, length: float = 4.0) -> str: """ Create a new MIDI clip in the specified track and clip slot. Parameters: - track_index: The index of the track to create the clip in - clip_index: The index of the clip slot to create the clip in - length: The length of the clip in beats (default: 4.0) """ try: ableton = get_ableton_connection() result = ableton.send_command("create_clip", { "track_index": track_index, "clip_index": clip_index, "length": length }) return f"Created new clip at track {track_index}, slot {clip_index} with length {length} beats" except Exception as e: logger.error(f"Error creating clip: {str(e)}") return f"Error creating clip: {str(e)}"
- Core implementation of clip creation using Ableton Live API: retrieves track and clip_slot then calls clip_slot.create_clip(length). Called by the remote script's command dispatcher.def _create_clip(self, track_index, clip_index, length): """Create a new MIDI clip in the specified track and clip slot""" try: if track_index < 0 or track_index >= len(self._song.tracks): raise IndexError("Track index out of range") track = self._song.tracks[track_index] if clip_index < 0 or clip_index >= len(track.clip_slots): raise IndexError("Clip index out of range") clip_slot = track.clip_slots[clip_index] # Check if the clip slot already has a clip if clip_slot.has_clip: raise Exception("Clip slot already has a clip") # Create the clip clip_slot.create_clip(length) result = { "name": clip_slot.clip.name, "length": clip_slot.clip.length } return result except Exception as e: self.log_message("Error creating clip: " + str(e)) raise
- AbletonMCP_Remote_Script/__init__.py:247-251 (registration)Command registration/dispatch in the Ableton remote script's socket command processor (_process_command). Routes 'create_clip' to the _create_clip handler.elif command_type == "create_clip": track_index = params.get("track_index", 0) clip_index = params.get("clip_index", 0) length = params.get("length", 4.0) result = self._create_clip(track_index, clip_index, length)
- MCP_Server/server.py:324-331 (schema)Tool schema defined by function parameters and docstring, used by FastMCP for input validation and tool description.""" Create a new MIDI clip in the specified track and clip slot. Parameters: - track_index: The index of the track to create the clip in - clip_index: The index of the clip slot to create the clip in - length: The length of the clip in beats (default: 4.0) """
- MCP_Server/server.py:104-109 (helper)List classifying 'create_clip' as a state-modifying command, which receives special handling (delays, timeouts) in the socket send_command method.is_modifying_command = command_type in [ "create_midi_track", "create_audio_track", "set_track_name", "create_clip", "add_notes_to_clip", "set_clip_name", "set_tempo", "fire_clip", "stop_clip", "set_device_parameter", "start_playback", "stop_playback", "load_instrument_or_effect" ]