get_devices
Retrieve available Spotify playback devices and identify the current default device for controlling music across connected speakers, phones, or computers.
Instructions
Get list of available Spotify devices and the current default device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:402-415 (handler)Handler logic for the 'get_devices' tool in the CallToolRequestHandler switch statement. Fetches devices using SpotifyClient and returns them along with the current default device.case 'get_devices': const devices = await client.getDevices(); return { content: [ { type: 'text', text: JSON.stringify({ success: true, devices, defaultDevice: deviceManager.getDefaultDevice(), }, null, 2), }, ], };
- src/server.ts:213-220 (registration)Registration of the 'get_devices' tool in the ListToolsRequestHandler, including name, description, and empty input schema.{ name: 'get_devices', description: 'Get list of available Spotify devices and the current default device', inputSchema: { type: 'object', properties: {}, }, },
- src/spotify/client.ts:173-183 (helper)Implementation of getDevices method in SpotifyClient class, which queries the Spotify API for available devices and maps the response.async getDevices() { const api = await this.getApi(); const data = await api.getMyDevices(); return data.body.devices.map((device: any) => ({ id: device.id, name: device.name, type: device.type, isActive: device.is_active, volumePercent: device.volume_percent || 0, })); }