Skip to main content
Glama
keenanbass1

TIDAL MCP Server

by keenanbass1

get_similar_artists

Find artists with similar musical styles to expand your listening preferences within the TIDAL music streaming service.

Instructions

Get artists similar to the specified artist.

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

Returns: List of similar artists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
artist_idYes
limitNo

Implementation Reference

  • The main handler function for the 'get_similar_artists' tool. It fetches the seed artist using tidalapi, retrieves similar artists via artist.get_similar(), limits the results, maps them to structured Artist models, and returns an ArtistList.
    @mcp.tool()
    async def get_similar_artists(artist_id: str, limit: int = 10) -> ArtistList:
        """
        Get artists similar to the specified artist.
    
        Args:
            artist_id: ID of the seed artist
            limit: Maximum artists to return (default: 10, max: 50)
    
        Returns:
            List of similar artists
        """
        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")
    
            similar = await anyio.to_thread.run_sync(artist.get_similar)
            limited_similar = similar[:limit] if similar else []
    
            artists = []
            for a in limited_similar:
                artists.append(
                    Artist(
                        id=str(a.id),
                        name=a.name,
                        url=f"https://tidal.com/browse/artist/{a.id}",
                    )
                )
    
            return ArtistList(
                status="success",
                count=len(artists),
                artists=artists,
            )
        except ToolError:
            raise
        except Exception as e:
            raise ToolError(f"Failed to get similar artists: {str(e)}")
  • Pydantic model defining the output schema for the tool: a list of similar artists with status, count, and Artist objects.
    class ArtistList(BaseModel):
        """List of artists 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 artists returned")
        artists: List[Artist] = Field(description="List of artist objects")
  • Pydantic model for individual Artist objects used in the ArtistList output.
    class Artist(BaseModel):
        """Structured representation of a TIDAL artist."""
    
        id: str = Field(description="Unique TIDAL artist ID")
        name: str = Field(description="Artist name")
        url: str = Field(description="TIDAL web URL for the artist")
  • Helper function used by the tool to ensure the user is authenticated with TIDAL before executing the logic.
    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)

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