Skip to main content
Glama
makesh-kumar

Spotify MCP Server

by makesh-kumar

playMusic

Start playing Spotify music by specifying tracks, albums, artists, or playlists using Spotify URIs or IDs. Control playback on specific devices through the Spotify MCP Server.

Instructions

Start playing a Spotify track, album, artist, or playlist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uriNoThe Spotify URI to play (overrides type and id)
typeNoThe type of item to play
idNoThe Spotify ID of the item to play
deviceIdNoThe Spotify device ID to play on

Implementation Reference

  • Handler function for playMusic tool that constructs Spotify URI from inputs and calls Spotify API to start/resume playback on specified device.
    handler: async (args, _extra: SpotifyHandlerExtra) => {
      const { uri, type, id, deviceId } = args;
    
      if (!(uri || (type && id))) {
        return {
          content: [
            {
              type: 'text',
              text: 'Error: Must provide either a URI or both a type and ID',
              isError: true,
            },
          ],
        };
      }
    
      let spotifyUri = uri;
      if (!spotifyUri && type && id) {
        spotifyUri = `spotify:${type}:${id}`;
      }
    
      await handleSpotifyRequest(async (spotifyApi) => {
        const device = deviceId || '';
    
        if (!spotifyUri) {
          await spotifyApi.player.startResumePlayback(device);
          return;
        }
    
        if (type === 'track') {
          await spotifyApi.player.startResumePlayback(device, undefined, [
            spotifyUri,
          ]);
        } else {
          await spotifyApi.player.startResumePlayback(device, spotifyUri);
        }
      });
    
      return {
        content: [
          {
            type: 'text',
            text: `Started playing ${type || 'music'} ${id ? `(ID: ${id})` : ''}`,
          },
        ],
      };
    },
  • Zod input schema for playMusic tool defining optional parameters: uri, type, id, deviceId.
    schema: {
      uri: z
        .string()
        .optional()
        .describe('The Spotify URI to play (overrides type and id)'),
      type: z
        .enum(['track', 'album', 'artist', 'playlist'])
        .optional()
        .describe('The type of item to play'),
      id: z.string().optional().describe('The Spotify ID of the item to play'),
      deviceId: z
        .string()
        .optional()
        .describe('The Spotify device ID to play on'),
    },
  • src/index.ts:12-14 (registration)
    Registers the playMusic tool (via playTools array) with the MCP server by calling server.tool() for each tool in the imported arrays.
    [...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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Start playing' but does not mention prerequisites (e.g., requires an active Spotify session or device), potential side effects (e.g., interrupts current playback), or limitations (e.g., rate limits, authentication needs). This leaves significant gaps in understanding the tool's behavior.

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 directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence contributes 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?

Given the complexity of a playback tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., interrupts current playback, requires device selection), error conditions, or what the tool returns. This makes it incomplete for safe and effective use by an AI agent.

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 input schema has 100% description coverage, so the schema already documents all parameters thoroughly. The description does not add any meaningful semantic context beyond what the schema provides, such as explaining the relationship between 'uri' and 'type/id' or typical usage patterns. This meets the baseline for high schema coverage.

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 ('Start playing') and the resource ('a Spotify track, album, artist, or playlist'), making the purpose immediately understandable. However, it does not explicitly differentiate from sibling tools like 'resumePlayback' or 'addToQueue', which could cause confusion about when to use this specific tool versus alternatives.

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 does not clarify if this should be used for initial playback versus resuming, or how it differs from 'resumePlayback' or 'addToQueue'. This lack of context could lead to incorrect tool selection by an AI agent.

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

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