Skip to main content
Glama
keenanbb

TIDAL MCP Server

by keenanbb

Authenticate with TIDAL

login

Authenticate with TIDAL music service using OAuth browser flow. Opens browser automatically for secure login and persists session for future interactions.

Instructions

Authenticate with TIDAL using OAuth browser flow. Opens browser automatically for secure login. Session is persisted for future use.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYesOperation status (success/error)
messageYesStatus message
authenticatedYesWhether authentication was successful

Implementation Reference

  • Implementation of the 'login' tool handler. Uses @mcp.tool decorator for automatic registration. Performs OAuth login via browser, persists session to file, checks authentication status.
    @mcp.tool(
        annotations={
            "title": "Authenticate with TIDAL",
            "readOnlyHint": False,
            "openWorldHint": True,
            "idempotentHint": False,
        }
    )
    async def login() -> AuthResult:
        """
        Authenticate with TIDAL using OAuth browser flow.
        Opens browser automatically for secure login.
        Session is persisted for future use.
        """
        if await ensure_authenticated():
            return AuthResult(
                status="success",
                message="Already authenticated with TIDAL",
                authenticated=True,
            )
    
        try:
            # Start OAuth device code flow
            login_obj, future = await anyio.to_thread.run_sync(session.login_oauth)
    
            auth_url = login_obj.verification_uri_complete
            if not auth_url.startswith("http"):
                auth_url = "https://" + auth_url
    
            # Try to open browser automatically
            try:
                await anyio.to_thread.run_sync(webbrowser.open, auth_url)
            except Exception:
                pass
    
            # Wait for user to complete authentication (polls TIDAL's server)
            # This blocks until auth completes or the link expires (~5 minutes)
            await anyio.to_thread.run_sync(future.result)
    
            # Check if login succeeded
            if await anyio.to_thread.run_sync(session.check_login):
                # Save session for future use
                session_data = {
                    "token_type": {"data": session.token_type or "Bearer"},
                    "session_id": {"data": session.session_id or ""},
                    "access_token": {"data": session.access_token},
                    "refresh_token": {"data": session.refresh_token},
                    "is_pkce": {"data": session.is_pkce},
                }
                async with await anyio.open_file(SESSION_FILE, "w") as f:
                    await f.write(json.dumps(session_data))
    
                return AuthResult(
                    status="success",
                    message="Successfully authenticated with TIDAL",
                    authenticated=True,
                )
            else:
                raise ToolError("Authentication failed - please try again")
        except ToolError:
            raise
        except Exception as e:
            error_msg = str(e)
            if "too long" in error_msg.lower() or "timeout" in error_msg.lower():
                raise ToolError(
                    f"Authentication timed out. Please authenticate using the helper script:\n\n"
                    f"  cd /home/ubuntu/code/personal/tidal/tidal-mcp && uv run python authenticate.py\n\n"
                    f"After authenticating, all MCP tools will work automatically."
                )
            raise ToolError(f"Authentication error: {error_msg}")
  • Pydantic BaseModel defining the structured output schema for the login tool response.
    class AuthResult(BaseModel):
        """Result of authentication attempt."""
    
        status: str = Field(description="Operation status (success/error)")
        message: str = Field(description="Status message")
        authenticated: bool = Field(description="Whether authentication was successful")
  • Helper function to check and load persisted authentication session. Used by login and all other authenticated tools.
    async def ensure_authenticated() -> bool:
        """
        Check if user is authenticated with TIDAL.
        Automatically loads persisted session if available.
        """
        if await anyio.Path(SESSION_FILE).exists():
            try:
                async with await anyio.open_file(SESSION_FILE, "r") as f:
                    content = await f.read()
                    data = json.loads(content)
    
                # Load OAuth session
                result = await anyio.to_thread.run_sync(
                    session.load_oauth_session,
                    data["token_type"]["data"],
                    data["access_token"]["data"],
                    data["refresh_token"]["data"],
                    None,  # expiry time
                )
    
                if result:
                    is_valid = await anyio.to_thread.run_sync(session.check_login)
                    if not is_valid:
                        await anyio.Path(SESSION_FILE).unlink()
                    return is_valid
                return False
            except Exception:
                await anyio.Path(SESSION_FILE).unlink()
                return False
    
        return await anyio.to_thread.run_sync(session.check_login)
  • @mcp.tool decorator registers the login function as an MCP tool with custom annotations.
    @mcp.tool(
        annotations={
            "title": "Authenticate with TIDAL",
            "readOnlyHint": False,
            "openWorldHint": True,
            "idempotentHint": False,
        }
    )
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds valuable behavioral context beyond annotations: it specifies the OAuth browser flow mechanism, mentions automatic browser opening, and states session persistence. While annotations cover some aspects (readOnlyHint=false, openWorldHint=true), the description provides practical implementation details that help the agent understand the user experience.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three concise sentences with zero waste: first states purpose and method, second describes the automatic browser behavior, third explains persistence. Each sentence earns its place by providing distinct, valuable information in a front-loaded manner.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is an authentication tool with 0 parameters, annotations present, and an output schema exists, the description is complete. It covers the authentication method, user interaction (browser opening), and session management - all essential context for an agent to understand and invoke this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0 parameters and 100% schema description coverage, the baseline would be 4. The description appropriately doesn't discuss parameters since none exist, and instead focuses on the authentication process itself, which is the correct semantic emphasis for this tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Authenticate with TIDAL using OAuth browser flow') and resource (TIDAL service), distinguishing it from all sibling tools which are data operations rather than authentication. It goes beyond the name/title by specifying the OAuth mechanism.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool ('Authenticate with TIDAL') and implies it's a prerequisite for other operations, but doesn't explicitly state when NOT to use it or name specific alternatives. The persistence statement suggests it's for initial setup rather than repeated use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/keenanbb/tidal-mcp'

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