remove_tracks_from_playlist
Delete specific songs from a TIDAL playlist using track IDs or position numbers to customize your music collection.
Instructions
Remove tracks from a playlist by track ID or position index.
Args: playlist_id: ID of the playlist track_ids: List of track IDs to remove (optional) indices: List of position indices to remove, 0-based (optional) Note: Provide either track_ids OR indices, not both
Returns: Success status and number of tracks removed
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_id | Yes | ||
| track_ids | No | ||
| indices | No |
Implementation Reference
- src/tidal_mcp/server.py:632-684 (handler)The primary handler function decorated with @mcp.tool(), implementing the logic to remove tracks from a TIDAL playlist by either track IDs or indices using the tidalapi session.@mcp.tool() async def remove_tracks_from_playlist( playlist_id: str, track_ids: Optional[List[str]] = None, indices: Optional[List[int]] = None ) -> RemoveTracksResult: """ Remove tracks from a playlist by track ID or position index. Args: playlist_id: ID of the playlist track_ids: List of track IDs to remove (optional) indices: List of position indices to remove, 0-based (optional) Note: Provide either track_ids OR indices, not both Returns: Success status and number of tracks removed """ if not await ensure_authenticated(): raise ToolError("Not authenticated. Please run the 'login' tool first.") if not track_ids and not indices: raise ToolError("Must provide either track_ids or indices to remove") if track_ids and indices: raise ToolError("Provide either track_ids or indices, not both") try: playlist = await anyio.to_thread.run_sync(session.playlist, playlist_id) if not playlist: raise ToolError(f"Playlist with ID '{playlist_id}' not found") if indices: # Remove by index position await anyio.to_thread.run_sync(playlist.remove_by_indices, indices) removed_count = len(indices) else: # Remove by track ID track_ids_int = [int(tid) for tid in track_ids] await anyio.to_thread.run_sync(playlist.remove_by_id, track_ids_int) removed_count = len(track_ids) return RemoveTracksResult( status="success", playlist_id=playlist_id, playlist_name=playlist.name, tracks_removed=removed_count, message=f"Removed {removed_count} tracks from playlist '{playlist.name}'", ) except ValueError as e: raise ToolError(f"Invalid ID format: {str(e)}") except ToolError: raise except Exception as e: raise ToolError(f"Failed to remove tracks: {str(e)}")
- src/tidal_mcp/models.py:150-158 (schema)Pydantic model defining the structured output schema for the remove_tracks_from_playlist tool response.class RemoveTracksResult(BaseModel): """Result of removing tracks from a playlist.""" status: str = Field(description="Operation status (success/error)") playlist_id: str = Field(description="ID of the playlist") playlist_name: str = Field(description="Name of the playlist") tracks_removed: int = Field(description="Number of tracks successfully removed") message: str = Field(description="Status message")
- src/tidal_mcp/server.py:632-632 (registration)The @mcp.tool() decorator from FastMCP that registers the remove_tracks_from_playlist function as an available MCP tool.@mcp.tool()