get_playlist
Retrieve a Spotify user's playlist details including tracks and metadata by providing the playlist ID or URI.
Instructions
Get a playlist owned by a Spotify user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The Spotify ID or URI of the playlist | |
| market | No | Optional. An ISO 3166-1 alpha-2 country code |
Implementation Reference
- src/handlers/playlists.ts:12-20 (handler)Core implementation of the 'get_playlist' tool. Normalizes the playlist ID, handles optional market parameter, and fetches playlist data via Spotify API GET /playlists/{id}.async getPlaylist(args: PlaylistArgs) { const playlistId = this.extractPlaylistId(args.id); const { market } = args; const params = { market }; return this.api.makeRequest( `/playlists/${playlistId}${this.api.buildQueryString(params)}` ); }
- src/types/playlists.ts:3-5 (schema)TypeScript type definition for input arguments: required 'id' (Spotify playlist ID or URI) extending MarketParams (optional market).export interface PlaylistArgs extends MarketParams { id: string; }
- src/index.ts:444-459 (registration)MCP tool registration in listTools response, including name, description, and JSON input schema.name: 'get_playlist', description: 'Get a playlist owned by a Spotify user', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'The Spotify ID or URI of the playlist' }, market: { type: 'string', description: 'Optional. An ISO 3166-1 alpha-2 country code' } }, required: ['id'] },
- src/index.ts:829-835 (registration)Dispatch handler in CallToolRequest that validates args and calls the playlistsHandler.getPlaylist.case 'get_playlist': { const args = this.validateArgs<PlaylistArgs>(request.params.arguments, ['id']); const result = await this.playlistsHandler.getPlaylist(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/handlers/playlists.ts:8-10 (helper)Utility method used by getPlaylist to normalize Spotify playlist URI to plain ID.private extractPlaylistId(id: string): string { return id.startsWith('spotify:playlist:') ? id.split(':')[2] : id; }