Skip to main content
Glama
keenanbb

TIDAL MCP Server

by keenanbb

search_tracks

Find music tracks on TIDAL by searching with artist names, song titles, or keywords to get detailed track information and streaming links.

Instructions

Search for tracks on TIDAL.

Args: query: Search query - artist name, song title, or combination limit: Maximum results (1-50, default: 10)

Returns: List of matching tracks with id, title, artist, album, duration, and URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesNumber of tracks returned
queryNoSearch query used (for search results)
statusYesOperation status (success/error)
tracksYesList of track objects

Implementation Reference

  • Handler function implementing the search_tracks tool: performs authentication check, calls TIDAL search API, constructs TrackList response.
    @mcp.tool()
    async def search_tracks(query: str, limit: int = 10) -> TrackList:
        """
        Search for tracks on TIDAL.
    
        Args:
            query: Search query - artist name, song title, or combination
            limit: Maximum results (1-50, default: 10)
    
        Returns:
            List of matching tracks with id, title, artist, album, duration, and URL
        """
        if not await ensure_authenticated():
            raise ToolError("Not authenticated. Please run the 'login' tool first.")
    
        try:
            limit = min(max(1, limit), 50)
            results = await anyio.to_thread.run_sync(
                lambda: session.search(query, models=[tidalapi.Track], limit=limit)
            )
    
            tracks = []
            for track in results.get("tracks", []):
                tracks.append(
                    Track(
                        id=str(track.id),
                        title=track.name,
                        artist=track.artist.name if track.artist else "Unknown Artist",
                        album=track.album.name if track.album else "Unknown Album",
                        duration_seconds=track.duration,
                        url=f"https://tidal.com/browse/track/{track.id}",
                    )
                )
    
            return TrackList(status="success", query=query, count=len(tracks), tracks=tracks)
        except Exception as e:
            raise ToolError(f"Track search failed: {str(e)}")
  • Pydantic output schema for search_tracks response containing list of tracks.
    class TrackList(BaseModel):
        """List of tracks with metadata."""
    
        status: str = Field(description="Operation status (success/error)")
        query: Optional[str] = Field(None, description="Search query used (for search results)")
        count: int = Field(description="Number of tracks returned")
        tracks: List[Track] = Field(description="List of track objects")
  • Pydantic model defining structure of individual Track objects returned by search_tracks.
    class Track(BaseModel):
        """Structured representation of a TIDAL track."""
    
        id: str = Field(description="Unique TIDAL track ID")
        title: str = Field(description="Track title")
        artist: str = Field(description="Primary artist name")
        album: str = Field(description="Album name")
        duration_seconds: int = Field(description="Track duration in seconds")
        url: str = Field(description="TIDAL web URL for the track")
  • FastMCP decorator registering the search_tracks function as a tool.
    @mcp.tool()
  • Helper function to ensure user authentication before executing search_tracks.
    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)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the return format ('List of matching tracks with id, title, artist, album, duration, and URL'), which adds value beyond the input schema. However, it lacks details on behavioral traits such as rate limits, authentication requirements (implied by TIDAL context but not stated), error handling, or pagination (only limit parameter is mentioned).

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?

The description is well-structured and concise, with three sentences that earn their place: purpose statement, parameter explanations, and return value description. It uses bullet-like formatting for clarity without unnecessary verbosity.

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

Completeness4/5

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

Given the tool's moderate complexity (2 parameters, search functionality), no annotations, and an output schema exists (implied by 'Returns' section), the description is mostly complete. It covers purpose, parameters, and return values adequately. However, it could improve by mentioning authentication needs or error cases, slightly reducing completeness for a search tool in a music service context.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate. It fully explains both parameters: 'query' as 'Search query - artist name, song title, or combination' and 'limit' as 'Maximum results (1-50, default: 10)', adding clear semantics beyond the bare schema. This effectively documents all parameters without relying on the schema.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Search for tracks on TIDAL' with the verb 'search' and resource 'tracks'. It distinguishes from siblings like search_albums and search_artists by specifying the resource type, but doesn't explicitly contrast with other search tools beyond the name.

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

Usage Guidelines3/5

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

The description implies usage through the parameter explanations (e.g., 'artist name, song title, or combination'), suggesting when to use it for track searches. However, it doesn't provide explicit guidance on when to choose this over alternatives like search_albums or get_track_radio, nor does it mention prerequisites like authentication (though login is a sibling tool).

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