Skip to main content
Glama

get_artist_top_tracks

Retrieve an artist's most popular tracks from TIDAL by providing the artist ID and optional limit.

Instructions

Get an artist's most popular tracks.

Args: artist_id: ID of the artist limit: Maximum tracks to return (default: 10, max: 50)

Returns: List of the artist's top tracks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
artist_idYes
limitNo

Implementation Reference

  • The core handler function for the 'get_artist_top_tracks' tool. Decorated with @mcp.tool() for registration in FastMCP. Fetches artist details, retrieves top tracks via TidalAPI's artist.get_top_tracks(), maps to Track models, and returns a TrackList response. Includes authentication check and error handling.
    @mcp.tool() async def get_artist_top_tracks(artist_id: str, limit: int = 10) -> TrackList: """ Get an artist's most popular tracks. Args: artist_id: ID of the artist limit: Maximum tracks to return (default: 10, max: 50) Returns: List of the artist's top tracks """ if not await ensure_authenticated(): raise ToolError("Not authenticated. Please run the 'login' tool first.") try: limit = min(max(1, limit), 50) artist = await anyio.to_thread.run_sync(session.artist, artist_id) if not artist: raise ToolError(f"Artist with ID '{artist_id}' not found") top_tracks = await anyio.to_thread.run_sync( lambda: artist.get_top_tracks(limit=limit) ) tracks = [] for track in top_tracks: tracks.append( Track( id=str(track.id), title=track.name, artist=track.artist.name if track.artist else artist.name, 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", count=len(tracks), tracks=tracks, ) except ToolError: raise except Exception as e: raise ToolError(f"Failed to get artist top tracks: {str(e)}")
  • Pydantic model defining the output schema for get_artist_top_tracks and other track list responses. Used as return type annotation in the handler.
    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 for individual Track objects used in TrackList responses by get_artist_top_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")
  • Tool description listed in SERVER_INSTRUCTIONS markdown, which is passed to FastMCP constructor to inform the model of available tools.
    - get_artist_top_tracks: Get an artist's most popular tracks

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

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