Skip to main content
Glama
marcelmarais

Spotify MCP Server

by marcelmarais

getAvailableDevices

Retrieve a list of Spotify Connect devices available for playback, enabling users to select where to stream music.

Instructions

Get information about the user's available Spotify Connect devices

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the tool logic: fetches available Spotify devices using the Spotify API, handles errors, and formats a list of devices with status, volume, and ID.
      handler: async (_args, _extra: SpotifyHandlerExtra) => {
        try {
          const devices = await handleSpotifyRequest(async (spotifyApi) => {
            return await spotifyApi.player.getAvailableDevices();
          });
    
          if (!devices.devices || devices.devices.length === 0) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'No available devices found. Make sure Spotify is open on at least one device.',
                },
              ],
            };
          }
    
          const formattedDevices = devices.devices
            .map((device, i) => {
              const status = device.is_active ? '▶ Active' : '○ Inactive';
              const volume =
                device.volume_percent !== null
                  ? `${device.volume_percent}%`
                  : 'N/A';
              const restricted = device.is_restricted ? ' (Restricted)' : '';
              return `${i + 1}. ${device.name} (${device.type})${restricted}\n   Status: ${status} | Volume: ${volume} | ID: ${device.id}`;
            })
            .join('\n\n');
    
          return {
            content: [
              {
                type: 'text',
                text: `# Available Spotify Devices\n\n${formattedDevices}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error getting available devices: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      },
    };
  • Schema definition for the getAvailableDevices tool, using tool<Record<string, never>> type indicating no input parameters, with empty schema object.
    const getAvailableDevices: tool<Record<string, never>> = {
      name: 'getAvailableDevices',
      description:
        "Get information about the user's available Spotify Connect devices",
      schema: {},
  • src/read.ts:603-612 (registration)
    Includes the getAvailableDevices tool in the exported readTools array, which is later used for registration.
    export const readTools = [
      searchSpotify,
      getNowPlaying,
      getMyPlaylists,
      getPlaylistTracks,
      getRecentlyPlayed,
      getUsersSavedTracks,
      getQueue,
      getAvailableDevices,
    ];
  • src/index.ts:12-14 (registration)
    Final registration of all tools including getAvailableDevices from readTools by calling server.tool() on the MCP server instance.
    [...readTools, ...playTools, ...albumTools].forEach((tool) => {
      server.tool(tool.name, tool.description, tool.schema, tool.handler);
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool does, not how it behaves. It lacks details like whether this requires user authentication, returns real-time or cached data, includes error handling, or provides device status (e.g., active/inactive), which are critical for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that directly states the tool's purpose without redundancy. It's appropriately sized for a zero-parameter tool and front-loaded with essential information, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what information is returned (e.g., device names, IDs, types, status), how the data is structured, or any limitations (e.g., only shows user's devices), leaving gaps for an AI agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, earning a high baseline score for not adding unnecessary information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get information') and resource ('available Spotify Connect devices'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'getNowPlaying' or 'getQueue' which also retrieve device-related information, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. For example, it doesn't specify if this should be used before 'playMusic' to select a device or how it relates to 'getNowPlaying' for current device status, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/marcelmarais/spotify-mcp-server'

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