get_library_songs
Retrieve songs from your Apple Music library with pagination controls to manage large collections efficiently.
Instructions
List songs saved in your Apple Music library.
Args: limit: Number of songs to return, 1–100 (default 25). offset: Pagination offset for retrieving subsequent pages (default 0).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
Implementation Reference
- src/mcp_apple_music/server.py:204-229 (handler)The handler function 'get_library_songs' implements the logic for fetching and returning library songs via the Apple Music API client.
async def get_library_songs(limit: int = 25, offset: int = 0) -> str: """List songs saved in your Apple Music library. Args: limit: Number of songs to return, 1–100 (default 25). offset: Pagination offset for retrieving subsequent pages (default 0). """ client = _get_client() data = await client.get( "/me/library/songs", params={"limit": min(max(1, limit), 100), "offset": max(0, offset)}, ) songs = data.get("data", []) total = data.get("meta", {}).get("total", "?") if not songs: return "No songs found in your library." lines = [f"🎵 Library Songs — showing {offset + 1}–{offset + len(songs)} of {total}:\n"] for i, s in enumerate(songs, offset + 1): lines.append(_fmt_song(s, i)) return "\n".join(lines) # ------------------------------------------------------------------ # # Tool: get_library_albums #