spotify_play_playlist
Play a specific Spotify playlist by providing its ID to start music playback on your preferred device.
Instructions
Toca uma playlist específica
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | No | ID do dispositivo (opcional) | |
| playlist_id | Yes | ID da playlist no Spotify |
Implementation Reference
- src/tools/spotify-tools.ts:464-494 (handler)The handler function that executes the logic to play a specific Spotify playlist using the Spotify API's play method with context_uri.async playPlaylist(playlistId: string, deviceId?: string) { try { await this.spotifyAuth.ensureValidToken(); const spotifyApi = this.spotifyAuth.getSpotifyApi(); const options: any = { context_uri: `spotify:playlist:${playlistId}` }; if (deviceId) { options.device_id = deviceId; } await spotifyApi.play(options); return { content: [ { type: 'text', text: `▶️ Tocando playlist com ID: ${playlistId}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Erro ao tocar playlist: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- src/index.ts:190-207 (schema)Input schema definition for the spotify_play_playlist tool, specifying parameters playlist_id (required) and optional device_id.{ name: 'spotify_play_playlist', description: 'Toca uma playlist específica', inputSchema: { type: 'object', properties: { playlist_id: { type: 'string', description: 'ID da playlist no Spotify', }, device_id: { type: 'string', description: 'ID do dispositivo (opcional)', }, }, required: ['playlist_id'], }, },
- src/index.ts:295-296 (registration)Registration in the CallToolRequest handler switch statement, dispatching to the playPlaylist method on SpotifyTools instance.case 'spotify_play_playlist': return await spotifyTools.playPlaylist(args.playlist_id, args.device_id);