Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

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);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Toca' implies a playback action, it doesn't specify whether this interrupts current playback, requires premium subscription, has rate limits, or what happens on success/failure. For a mutation tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a simple playback function and front-loads the essential information.

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?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after invocation (does it return success status? error messages? playback confirmation?), nor does it address authentication requirements or potential limitations. Given the complexity of media playback operations, more context is needed.

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

Parameters3/5

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

The schema has 100% description coverage, with both parameters clearly documented in the schema itself. The description doesn't add any parameter information beyond what's already in the schema, so it meets the baseline of 3 when the schema does the heavy lifting.

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 ('Toca' - plays) and the resource ('uma música específica no Spotify'), making the purpose immediately understandable. However, it doesn't differentiate this tool from similar sibling tools like 'spotify_play_playlist' or 'spotify_resume', which also involve playback functionality.

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 like 'spotify_play_playlist' (for playing entire playlists) or 'spotify_resume' (for resuming playback). There's no mention of prerequisites (like authentication status) or context about when this specific track-playing function is appropriate.

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/fborello/MCPSpotify'

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