Skip to main content
Glama
keenanbb

TIDAL MCP Server

by keenanbb

get_artist_albums

Retrieve an artist's discography from TIDAL by providing their artist ID to access albums and track listings.

Instructions

Get albums by an artist (discography).

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

Returns: List of albums by the artist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
artist_idYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesNumber of albums returned
queryNoSearch query used (for search results)
albumsYesList of album objects
statusYesOperation status (success/error)

Implementation Reference

  • The handler function implementing the get_artist_albums tool. It authenticates, fetches the artist, retrieves their albums via tidalapi, constructs Album objects, and returns an AlbumList.
    @mcp.tool()
    async def get_artist_albums(artist_id: str, limit: int = 20) -> AlbumList:
        """
        Get albums by an artist (discography).
    
        Args:
            artist_id: ID of the artist
            limit: Maximum albums to return (default: 20, max: 50)
    
        Returns:
            List of albums by the artist
        """
        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")
    
            artist_albums = await anyio.to_thread.run_sync(
                lambda: artist.get_albums(limit=limit)
            )
    
            albums = []
            for album in artist_albums:
                release_date = None
                if hasattr(album, "release_date") and album.release_date:
                    release_date = str(album.release_date)
    
                albums.append(
                    Album(
                        id=str(album.id),
                        title=album.name,
                        artist=album.artist.name if album.artist else artist.name,
                        release_date=release_date,
                        num_tracks=getattr(album, "num_tracks", 0),
                        duration_seconds=getattr(album, "duration", 0),
                        url=f"https://tidal.com/browse/album/{album.id}",
                    )
                )
    
            return AlbumList(
                status="success",
                count=len(albums),
                albums=albums,
            )
        except ToolError:
            raise
        except Exception as e:
            raise ToolError(f"Failed to get artist albums: {str(e)}")
  • Pydantic BaseModel defining the output structure AlbumList for the get_artist_albums tool response.
    class AlbumList(BaseModel):
        """List of albums 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 albums returned")
        albums: List[Album] = Field(description="List of album objects")
  • Pydantic BaseModel defining the Album entity used within the AlbumList output of get_artist_albums.
    class Album(BaseModel):
        """Structured representation of a TIDAL album."""
    
        id: str = Field(description="Unique TIDAL album ID")
        title: str = Field(description="Album title")
        artist: str = Field(description="Primary artist name")
        release_date: Optional[str] = Field(None, description="Release date (YYYY-MM-DD)")
        num_tracks: int = Field(description="Number of tracks in album")
        duration_seconds: int = Field(description="Total album duration in seconds")
        url: str = Field(description="TIDAL web URL for the album")
  • Helper function used by get_artist_albums to ensure user authentication before API calls.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the return type ('List of albums') and default/max limits, but lacks details on permissions, rate limits, pagination (e.g., if limit is exceeded), error handling, or whether it's a read-only operation. This is a significant gap for a tool with no annotation coverage.

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

Conciseness4/5

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

The description is well-structured with clear sections (Args, Returns) and front-loaded purpose. Every sentence adds value: the first states the tool's function, and the subsequent lines detail parameters and returns. It could be slightly more concise by integrating the limit details into a single line, but it's efficient overall.

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 low complexity (2 parameters, no nested objects) and the presence of an output schema (which handles return values), the description is reasonably complete. It covers the purpose and parameters adequately, though it lacks behavioral context (e.g., auth needs, error cases), which holds it back from a perfect score.

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 fully compensate. It explicitly documents both parameters: 'artist_id' as the ID of the artist and 'limit' with its default (20) and maximum (50) values, adding crucial meaning beyond the bare schema (which only specifies types and requirements).

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 ('Get albums by an artist') and resource ('discography'), distinguishing it from siblings like 'get_artist' (which likely returns artist info) or 'search_albums' (which searches across artists). The term 'discography' adds precision about the scope of albums returned.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention how it differs from 'get_album' (which might fetch a single album) or 'search_albums' (which might search by name rather than artist ID), leaving the agent to infer usage from context alone.

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