create_midi_track_tool
Generate a new MIDI track directly in Ableton Live using the Model Context Protocol, enabling AI-assisted music production and streamlined track creation.
Instructions
Create a new MIDI track in the Ableton session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | No |
Implementation Reference
- MCP_Server/server.py:75-79 (handler)MCP tool handler for 'create_midi_track_tool', registered via @mcp.tool() decorator. Executes by calling the create_midi_track helper function.@mcp.tool() def create_midi_track_tool(ctx: Context, index: int = -1) -> str: """Create a new MIDI track in the Ableton session.""" return create_midi_track(ctx, index)
- Core helper function implementing the MIDI track creation logic by sending a command over the connection to the Ableton remote script.def create_midi_track(ctx: Context, index: int = -1) -> str: """ Create a new MIDI track in the Ableton session. Parameters: - index: The index to insert the track at (-1 = end of list) """ try: ableton = get_ableton_connection() result = ableton.send_command("create_midi_track", {"index": index}) return f"Created new MIDI track: {result.get('name', 'unknown')}" except Exception as e: logger.error(f"Error creating MIDI track: {str(e)}") return f"Error creating MIDI track: {str(e)}"
- Part of CommandType enum defining the internal command string 'create_midi_track' used for communication with the remote script.CREATE_MIDI_TRACK = "create_midi_track"
- Implementation in the Ableton remote script handler that directly calls Ableton Live's song.create_midi_track(index).def create_midi_track(self, index: int) -> dict[str, Any]: """Create a new MIDI track at the specified index""" try: # Create the track self._song.create_midi_track(index) # Get the new track new_track_index = len(self._song.tracks) - 1 if index == -1 else index new_track = self._song.tracks[new_track_index] result = {"index": new_track_index, "name": new_track.name} return result except Exception as e: self.log_message("Error creating MIDI track: " + str(e)) raise