Skip to main content
Glama
keenanbass1

TIDAL MCP Server

by keenanbass1

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
NameRequiredDescriptionDefault
playlist_idYes
track_idsNo
indicesNo

Implementation Reference

  • 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)}")
  • 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")
  • The @mcp.tool() decorator from FastMCP that registers the remove_tracks_from_playlist function as an available MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/keenanbass1/tidal-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server