create_clip
Generate a new MIDI clip in Ableton Live by specifying the track, clip slot, and length, enabling precise control over music production within AI-assisted 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 |
|---|---|---|---|
| clip_index | Yes | ||
| length | No | ||
| track_index | Yes |
Implementation Reference
- MCP_Server/server.py:322-342 (handler)Primary MCP tool handler for 'create_clip', including registration via @mcp.tool(), input schema via type hints and docstring, and logic that forwards the command to the Ableton remote script connection.@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)}"
- Supporting helper function in the Ableton Live Remote Script that implements the actual clip creation using the Live Python API (clip_slot.create_clip(length)). This is invoked when the server forwards the 'create_clip' command.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 dispatch/registration in the remote script's main receive loop that handles incoming 'create_clip' commands from the MCP server and delegates to the _create_clip helper.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)