Skip to main content
Glama

spotify_play

Play a specific song on Spotify by providing the track ID. Control playback on your connected devices using this music streaming tool.

Instructions

Toca uma música específica no Spotify

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNoID do dispositivo (opcional)
track_idYesID da música no Spotify

Implementation Reference

  • The `play` method in the `SpotifyTools` class that executes the core logic for the `spotify_play` tool by calling the Spotify API to play a specific track URI, handling optional device selection and error responses.
    async play(trackId: string, deviceId?: string) { try { await this.spotifyAuth.ensureValidToken(); const spotifyApi = this.spotifyAuth.getSpotifyApi(); const options: any = { uris: [`spotify:track:${trackId}`] }; if (deviceId) { options.device_id = deviceId; } await spotifyApi.play(options); return { content: [ { type: 'text', text: `▶️ Tocando música com ID: ${trackId}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Erro ao tocar música: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Input schema definition for the `spotify_play` tool in the `ListToolsRequestSchema` handler, specifying `track_id` as required and `device_id` as optional.
    { name: 'spotify_play', description: 'Toca uma música específica no Spotify', inputSchema: { type: 'object', properties: { track_id: { type: 'string', description: 'ID da música no Spotify', }, device_id: { type: 'string', description: 'ID do dispositivo (opcional)', }, }, required: ['track_id'], }, },
  • src/index.ts:271-272 (registration)
    Registration and dispatch logic in the `CallToolRequestSchema` handler that routes `spotify_play` tool calls to the `SpotifyTools.play` method with parsed arguments.
    case 'spotify_play': return await spotifyTools.play(args.track_id, args.device_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/fborello/MCPSpotify'

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