get_playlist_tracks
Retrieve and display all tracks from a specified TIDAL playlist. Includes track name, artist, album, and duration for organized viewing. Use the playlist_id to fetch detailed song information.
Instructions
Retrieves all tracks from a specified TIDAL playlist.
USE THIS TOOL WHENEVER A USER ASKS FOR:
- "Show me the songs in my playlist"
- "What tracks are in my [playlist name] playlist?"
- "List the songs from my playlist"
- "Get tracks from my playlist"
- "View contents of my TIDAL playlist"
- Any request to see what songs/tracks are in a specific playlist
This function retrieves all tracks from a specific playlist in the user's TIDAL account.
The playlist_id must be provided, which can be obtained from the get_user_playlists() function.
When processing the results of this tool:
1. Present the playlist information (title, description, track count) as context
2. List the tracks in a clear, organized format with track name, artist, and album
3. Include track durations where available
4. Mention the total number of tracks in the playlist
5. If there are many tracks, focus on highlighting interesting patterns or variety
Args:
playlist_id: The TIDAL ID of the playlist to retrieve (required)
limit: Maximum number of tracks to retrieve (default: 100)
Returns:
A dictionary containing the playlist information and all tracks in the playlist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| playlist_id | Yes |
Implementation Reference
- mcp_server/server.py:453-536 (handler)The primary MCP tool handler for 'get_playlist_tracks', decorated with @mcp.tool() which also serves as registration. It validates inputs, checks authentication, and proxies the request to the backend Flask API endpoint.@mcp.tool() def get_playlist_tracks(playlist_id: str, limit: int = 100) -> dict: """ Retrieves all tracks from a specified TIDAL playlist. USE THIS TOOL WHENEVER A USER ASKS FOR: - "Show me the songs in my playlist" - "What tracks are in my [playlist name] playlist?" - "List the songs from my playlist" - "Get tracks from my playlist" - "View contents of my TIDAL playlist" - Any request to see what songs/tracks are in a specific playlist This function retrieves all tracks from a specific playlist in the user's TIDAL account. The playlist_id must be provided, which can be obtained from the get_user_playlists() function. When processing the results of this tool: 1. Present the playlist information (title, description, track count) as context 2. List the tracks in a clear, organized format with track name, artist, and album 3. Include track durations where available 4. Mention the total number of tracks in the playlist 5. If there are many tracks, focus on highlighting interesting patterns or variety Args: playlist_id: The TIDAL ID of the playlist to retrieve (required) limit: Maximum number of tracks to retrieve (default: 100) Returns: A dictionary containing the playlist information and all tracks in the playlist """ # First, check if the user is authenticated auth_check = requests.get(f"{FLASK_APP_URL}/api/auth/status") auth_data = auth_check.json() if not auth_data.get("authenticated", False): return { "status": "error", "message": "You need to login to TIDAL first before I can fetch playlist tracks. Please use the tidal_login() function." } # Validate playlist_id if not playlist_id: return { "status": "error", "message": "A playlist ID is required. You can get playlist IDs by using the get_user_playlists() function." } try: # Call the Flask endpoint to retrieve tracks from the playlist response = requests.get( f"{FLASK_APP_URL}/api/playlists/{playlist_id}/tracks", params={"limit": limit} ) # Check if the request was successful if response.status_code == 200: data = response.json() return { "status": "success", "tracks": data.get("tracks", []), "track_count": data.get("total_tracks", 0) } elif response.status_code == 404: return { "status": "error", "message": f"Playlist with ID {playlist_id} not found. Please check the playlist ID and try again." } elif response.status_code == 401: return { "status": "error", "message": "Not authenticated with TIDAL. Please login first using tidal_login()." } else: error_data = response.json() return { "status": "error", "message": f"Failed to retrieve playlist tracks: {error_data.get('error', 'Unknown error')}" } except Exception as e: return { "status": "error", "message": f"Failed to connect to TIDAL playlist service: {str(e)}" }
- tidal_api/app.py:330-359 (helper)The core helper function implementing the Flask endpoint that fetches and formats tracks from a Tidal playlist using the authenticated BrowserSession. This is called by the MCP handler.@app.route('/api/playlists/<playlist_id>/tracks', methods=['GET']) @requires_tidal_auth def get_playlist_tracks(playlist_id: str, session: BrowserSession): """ Get tracks from a specific TIDAL playlist. """ try: # Get limit from query parameter, default to 100 if not specified limit = bound_limit(request.args.get('limit', default=100, type=int)) # Get the playlist object playlist = session.playlist(playlist_id) if not playlist: return jsonify({"error": f"Playlist with ID {playlist_id} not found"}), 404 # Get tracks from the playlist with pagination if needed tracks = playlist.items(limit=limit) # Format track data track_list = [format_track_data(track) for track in tracks] return jsonify({ "playlist_id": playlist.id, "tracks": track_list, "total_tracks": len(track_list) }) except Exception as e: return jsonify({"error": f"Error fetching playlist tracks: {str(e)}"}), 500