create_tidal_playlist
Generate a personalized TIDAL playlist by adding selected tracks to a new collection in your account. Authenticate, specify a title, and receive a shareable playlist URL for immediate access.
Instructions
Creates a new TIDAL playlist with the specified tracks.
USE THIS TOOL WHENEVER A USER ASKS FOR:
- "Create a playlist with these songs"
- "Make a TIDAL playlist"
- "Save these tracks to a playlist"
- "Create a collection of songs"
- Any request to create a new playlist in their TIDAL account
This function creates a new playlist in the user's TIDAL account and adds the specified tracks to it.
The user must be authenticated with TIDAL first.
NAMING CONVENTION GUIDANCE:
When suggesting or creating a playlist, first check the user's existing playlists using get_user_playlists()
to understand their naming preferences. Some patterns to look for:
- Do they use emoji in playlist names?
- Do they use all caps, title case, or lowercase?
- Do they include dates or seasons in names?
- Do they name by mood, genre, activity, or artist?
- Do they use specific prefixes or formatting (e.g., "Mix: Summer Vibes" or "[Workout] High Energy")
Try to match their style when suggesting new playlist names. If they have no playlists yet or you
can't determine a pattern, use a clear, descriptive name based on the tracks' common themes.
When processing the results of this tool:
1. Confirm the playlist was created successfully
2. Provide the playlist title, number of tracks added, and URL
3. Always include the direct TIDAL URL (https://tidal.com/playlist/{playlist_id})
4. Suggest that the user can now access this playlist in their TIDAL account
Args:
title: The name of the playlist to create
track_ids: List of TIDAL track IDs to add to the playlist
description: Optional description for the playlist (default: "")
Returns:
A dictionary containing the status of the playlist creation and details about the created playlist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| title | Yes | ||
| track_ids | Yes |
Implementation Reference
- mcp_server/server.py:284-388 (handler)MCP tool handler and registration for 'create_tidal_playlist'. Validates authentication and inputs, then proxies POST request to Flask /api/playlists endpoint with title, description, and track_ids. Handles response including adding Tidal playlist URL.@mcp.tool() def create_tidal_playlist(title: str, track_ids: list, description: str = "") -> dict: """ Creates a new TIDAL playlist with the specified tracks. USE THIS TOOL WHENEVER A USER ASKS FOR: - "Create a playlist with these songs" - "Make a TIDAL playlist" - "Save these tracks to a playlist" - "Create a collection of songs" - Any request to create a new playlist in their TIDAL account This function creates a new playlist in the user's TIDAL account and adds the specified tracks to it. The user must be authenticated with TIDAL first. NAMING CONVENTION GUIDANCE: When suggesting or creating a playlist, first check the user's existing playlists using get_user_playlists() to understand their naming preferences. Some patterns to look for: - Do they use emoji in playlist names? - Do they use all caps, title case, or lowercase? - Do they include dates or seasons in names? - Do they name by mood, genre, activity, or artist? - Do they use specific prefixes or formatting (e.g., "Mix: Summer Vibes" or "[Workout] High Energy") Try to match their style when suggesting new playlist names. If they have no playlists yet or you can't determine a pattern, use a clear, descriptive name based on the tracks' common themes. When processing the results of this tool: 1. Confirm the playlist was created successfully 2. Provide the playlist title, number of tracks added, and URL 3. Always include the direct TIDAL URL (https://tidal.com/playlist/{playlist_id}) 4. Suggest that the user can now access this playlist in their TIDAL account Args: title: The name of the playlist to create track_ids: List of TIDAL track IDs to add to the playlist description: Optional description for the playlist (default: "") Returns: A dictionary containing the status of the playlist creation and details about the created playlist """ try: # 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 creating a playlist. Please use the tidal_login() function." } # Validate inputs if not title: return { "status": "error", "message": "Playlist title cannot be empty." } if not track_ids or not isinstance(track_ids, list) or len(track_ids) == 0: return { "status": "error", "message": "You must provide at least one track ID to add to the playlist." } # Create the playlist through the Flask API payload = { "title": title, "description": description, "track_ids": track_ids } response = requests.post(f"{FLASK_APP_URL}/api/playlists", json=payload) # Check response if response.status_code != 200: error_data = response.json() return { "status": "error", "message": f"Failed to create playlist: {error_data.get('error', 'Unknown error')}" } # Parse the response result = response.json() playlist_data = result.get("playlist", {}) # Get the playlist ID playlist_id = playlist_data.get("id") # Format the TIDAL URL playlist_url = f"https://tidal.com/playlist/{playlist_id}" if playlist_id else None playlist_data["playlist_url"] = playlist_url return { "status": "success", "message": f"Successfully created playlist '{title}' with {len(track_ids)} tracks", "playlist": playlist_data } except Exception as e: return { "status": "error", "message": f"Failed to create playlist: {str(e)}" }
- tidal_api/app.py:229-291 (helper)Backend Flask endpoint '/api/playlists' (POST) that implements playlist creation using Tidal API: session.user.create_playlist(title, description) followed by playlist.add(track_ids). Returns playlist details. Called by the MCP tool handler.@app.route('/api/playlists', methods=['POST']) @requires_tidal_auth def create_playlist(session: BrowserSession): """ Creates a new TIDAL playlist and adds tracks to it. Expected JSON payload: { "title": "Playlist title", "description": "Playlist description", "track_ids": [123456789, 987654321, ...] } Returns the created playlist information. """ try: # Get request data request_data = request.get_json() if not request_data: return jsonify({"error": "Missing request body"}), 400 # Validate required fields if 'title' not in request_data: return jsonify({"error": "Missing 'title' in request body"}), 400 if 'track_ids' not in request_data or not request_data['track_ids']: return jsonify({"error": "Missing 'track_ids' in request body or empty track list"}), 400 # Get parameters from request title = request_data['title'] description = request_data.get('description', '') # Optional track_ids = request_data['track_ids'] # Validate track_ids is a list if not isinstance(track_ids, list): return jsonify({"error": "'track_ids' must be a list"}), 400 # Create the playlist playlist = session.user.create_playlist(title, description) # Add tracks to the playlist playlist.add(track_ids) # Return playlist information playlist_info = { "id": playlist.id, "title": playlist.name, "description": playlist.description, "created": playlist.created, "last_updated": playlist.last_updated, "track_count": playlist.num_tracks, "duration": playlist.duration, } return jsonify({ "status": "success", "message": f"Playlist '{title}' created successfully with {len(track_ids)} tracks", "playlist": playlist_info }) except Exception as e: return jsonify({"error": f"Error creating playlist: {str(e)}"}), 500