delete_track
Delete a track from a REAPER project by specifying its index number. Remove unwanted tracks to simplify your project structure.
Instructions
Delete a track by its index.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| track_index | Yes |
Implementation Reference
- src/reaper_mcp/track_tools.py:40-49 (handler)The delete_track function that executes the tool logic. It gets the project, finds the track by index, and calls RPR.DeleteTrack(track.id) to delete it.
@mcp.tool() def delete_track(track_index: int) -> dict: """Delete a track by its index.""" try: project = get_project() track = project.tracks[track_index] RPR.DeleteTrack(track.id) return {"success": True, "deleted_index": track_index} except Exception as e: return {"success": False, "error": str(e)} - src/reaper_mcp/track_tools.py:41-41 (schema)The delete_track function signature takes a single int parameter 'track_index' and returns a dict — this defines the input schema for the MCP tool.
def delete_track(track_index: int) -> dict: - src/reaper_mcp/track_tools.py:11-49 (registration)The @mcp.tool() decorator on line 40 registers delete_track as an MCP tool. The register_tools function is called from server.py where the mcp instance is wired up.
def register_tools(mcp): @mcp.tool() def create_track(name: str, track_type: str = "audio") -> dict: """ Create a new track at the end of the project. track_type: audio, midi, instrument, folder """ try: project = get_project() idx = project.n_tracks project.add_track(idx, name) track = project.tracks[idx] if track_type in ("midi", "instrument"): RPR.SetMediaTrackInfo_Value(track.id, "I_RECINPUT", 4096) # All MIDI inputs elif track_type == "folder": RPR.SetMediaTrackInfo_Value(track.id, "I_FOLDERDEPTH", 1) return { "success": True, "track_index": idx, "name": track.name, "type": track_type, } except Exception as e: logger.error(f"create_track failed: {e}") return {"success": False, "error": str(e)} @mcp.tool() def delete_track(track_index: int) -> dict: """Delete a track by its index.""" try: project = get_project() track = project.tracks[track_index] RPR.DeleteTrack(track.id) return {"success": True, "deleted_index": track_index} except Exception as e: return {"success": False, "error": str(e)} - src/reaper_mcp/server.py:20-21 (registration)Registration wiring: _reg_track(mcp) is called, which triggers the @mcp.tool() decorators in track_tools.py.
_reg_project(mcp) _reg_track(mcp) - src/reaper_mcp/connection.py:27-29 (helper)The get_project() helper used by delete_track to obtain the current REAPER project.
def get_project() -> reapy.Project: ensure_connected() return reapy.Project()