get_recently_played
Retrieve recently played albums, playlists, and stations from Apple Music to review your listening history and rediscover content.
Instructions
Get your recently played albums, playlists, and stations.
Note: Apple Music API returns recently-played containers (albums, playlists, stations) rather than individual tracks.
Args: limit: Number of items to return, 1–50 (default 10).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- src/mcp_apple_music/server.py:416-444 (handler)The implementation of the get_recently_played tool, which fetches recently played items from the Apple Music API using the authenticated client.
async def get_recently_played(limit: int = 10) -> str: """Get your recently played albums, playlists, and stations. Note: Apple Music API returns recently-played containers (albums, playlists, stations) rather than individual tracks. Args: limit: Number of items to return, 1–50 (default 10). """ client = _get_client() data = await client.get( "/me/recent/played", params={"limit": min(max(1, limit), 50)}, ) items = data.get("data", []) if not items: return "No recently played items found." lines = [f"🕐 Recently Played ({len(items)} items):\n"] for i, item in enumerate(items, 1): a = item.get("attributes", {}) t = item.get("type", "") pid = item.get("id", "?") name = a.get("name", "?") if "album" in t: emoji = "💿" detail = f" — {a.get('artistName', '')}" - src/mcp_apple_music/server.py:415-415 (registration)Registration of the get_recently_played function as an MCP tool using the @mcp.tool() decorator.
@mcp.tool()