Skip to main content
Glama
Cifero74

mcp-apple-music

get_playlist_tracks

Retrieve track listings from Apple Music playlists by providing a playlist ID, enabling users to view and manage their music library content.

Instructions

Get the tracks inside a specific playlist.

Args: playlist_id: Library playlist ID (starts with 'p.'). Use get_library_playlists to find IDs. limit: Maximum tracks to return, 1–100 (default 100).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_idYes
limitNo

Implementation Reference

  • The implementation of the get_playlist_tracks tool handler, which fetches tracks from a specific Apple Music playlist using the library client.
    @mcp.tool()
    async def get_playlist_tracks(playlist_id: str, limit: int = 100) -> str:
        """Get the tracks inside a specific playlist.
    
        Args:
            playlist_id: Library playlist ID (starts with 'p.').
                         Use get_library_playlists to find IDs.
            limit: Maximum tracks to return, 1–100 (default 100).
        """
        client = _get_client()
        data = await client.get(
            f"/me/library/playlists/{playlist_id}/tracks",
            params={"limit": min(max(1, limit), 100)},
        )
        tracks = data.get("data", [])
    
        if not tracks:
            return f"No tracks found in playlist '{playlist_id}'."
    
        lines = [f"🎵 Tracks in playlist [{playlist_id}] — {len(tracks)} tracks:\n"]
        for i, t in enumerate(tracks, 1):
            a = t.get("attributes", {})
            lines.append(
                f"  {i}. {a.get('name', '?')} — {a.get('artistName', '?')}"
                f" | Type: {t.get('type', '?')} | ID: {t.get('id', '?')}"
            )

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/Cifero74/mcp-apple-music'

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