Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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: {}, }, },
  • Dispatch case in the CallToolRequestHandler switch statement that invokes the spotifyTools.getDevices() handler.
    case 'spotify_devices': return await spotifyTools.getDevices();
  • 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; }

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