tidal_login
Authenticate with TIDAL via browser login flow to access personalized music recommendations and manage playlists in your TIDAL account.
Instructions
Authenticate with TIDAL through browser login flow.
This will open a browser window for the user to log in to their TIDAL account.
Returns:
A dictionary containing authentication status and user information if successful
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server/server.py:22-49 (handler)MCP tool handler for 'tidal_login', registered via @mcp.tool() decorator. Proxies authentication request to the Flask backend endpoint.@mcp.tool() def tidal_login() -> dict: """ Authenticate with TIDAL through browser login flow. This will open a browser window for the user to log in to their TIDAL account. Returns: A dictionary containing authentication status and user information if successful """ try: # Call your Flask endpoint for TIDAL authentication response = requests.get(f"{FLASK_APP_URL}/api/auth/login") # Check if the request was successful if response.status_code == 200: return response.json() else: error_data = response.json() return { "status": "error", "message": f"Authentication failed: {error_data.get('message', 'Unknown error')}" } except Exception as e: return { "status": "error", "message": f"Failed to connect to TIDAL authentication service: {str(e)}" }
- tidal_api/app.py:39-78 (helper)Flask API endpoint '/api/auth/login' that handles the authentication logic, called by the MCP handler. Uses BrowserSession to perform login.@app.route('/api/auth/login', methods=['GET']) def login(): """ Initiates the TIDAL authentication process. Automatically opens a browser for the user to login to their TIDAL account. """ # Create our custom session object session = BrowserSession() def log_message(msg): print(f"TIDAL AUTH: {msg}") # Try to authenticate (will open browser if needed) try: login_success = session.login_session_file_auto(SESSION_FILE, fn_print=log_message) if login_success: return jsonify({ "status": "success", "message": "Successfully authenticated with TIDAL", "user_id": session.user.id }) else: return jsonify({ "status": "error", "message": "Authentication failed" }), 401 except TimeoutError: return jsonify({ "status": "error", "message": "Authentication timed out" }), 408 except Exception as e: return jsonify({ "status": "error", "message": str(e) }), 500
- tidal_api/browser_session.py:33-65 (helper)Core login method in BrowserSession class: 'login_session_file_auto'. Loads existing session or initiates browser-based OAuth flow if needed.def login_session_file_auto( self, session_file: Path, do_pkce: Optional[bool] = False, fn_print: Callable[[str], None] = print, ) -> bool: """ Logs in to the TIDAL api using an existing OAuth/PKCE session file, automatically opening the browser for authentication if needed. :param session_file: The session json file :param do_pkce: Perform PKCE login. Default: Use OAuth logon :param fn_print: A function to display information :return: Returns true if the login was successful """ self.load_session_from_file(session_file) # Session could not be loaded, attempt to create a new session if not self.check_login(): if do_pkce: fn_print("Creating new session (PKCE)...") self.login_pkce(fn_print=fn_print) else: fn_print("Creating new session (OAuth)...") self.login_oauth_simple(fn_print=fn_print) if self.check_login(): fn_print(f"TIDAL Login OK, creds saved in {str(session_file)}") self.save_session_to_file(session_file) return True else: fn_print("TIDAL Login KO") return False