spotify_devices
List available playback devices connected to your Spotify account to manage where music plays from.
Instructions
Lista dispositivos disponíveis para reprodução
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/spotify-tools.ts:361-407 (handler)The core handler function for 'spotify_devices' tool. Ensures valid token, fetches available devices via SpotifyWebApi's getMyDevices(), formats and returns a markdown list of devices with details like ID, status, volume.async getDevices() { try { await this.spotifyAuth.ensureValidToken(); const spotifyApi = this.spotifyAuth.getSpotifyApi(); const response = await spotifyApi.getMyDevices(); const devices = response.body.devices; if (devices.length === 0) { return { content: [ { type: 'text', text: '❌ Nenhum dispositivo encontrado. Certifique-se de que o Spotify está aberto em algum dispositivo.', }, ], }; } let content = `📱 **Dispositivos disponíveis:**\n\n`; devices.forEach((device: any, index: number) => { const status = device.is_active ? '🟢 Ativo' : '⚪ Inativo'; content += `${index + 1}. **${device.name}** (${device.type})\n`; content += ` ID: ${device.id}\n`; content += ` Status: ${status}\n`; content += ` Volume: ${device.volume_percent}%\n\n`; }); return { content: [ { type: 'text', text: content, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Erro ao obter dispositivos: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- src/index.ts:169-176 (registration)Registration of the 'spotify_devices' tool in the ListToolsRequestHandler, including name, description, and empty input schema (no parameters required).{ name: 'spotify_devices', description: 'Lista dispositivos disponíveis para reprodução', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:289-290 (handler)Dispatch case in the CallToolRequestHandler switch statement that invokes the spotifyTools.getDevices() handler.case 'spotify_devices': return await spotifyTools.getDevices();
- src/types/index.ts:52-60 (schema)TypeScript interface defining the structure of a SpotifyDevice, used implicitly in the tool's output processing.export interface SpotifyDevice { id: string; is_active: boolean; is_private_session: boolean; is_restricted: boolean; name: string; type: string; volume_percent: number; }