Skip to main content
Glama
makesh-kumar

Spotify MCP Server

by makesh-kumar

getQueue

Retrieve the currently playing track and upcoming items in your Spotify queue to see what's next in your listening session.

Instructions

Get a list of the currently playing track and the next items in your Spotify queue

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of upcoming items to show (1-50)

Implementation Reference

  • The handler function that implements the core logic of the getQueue tool. It fetches the current Spotify queue, handles the currently playing track and upcoming tracks, formats them nicely, and returns a markdown-formatted response.
    handler: async (args, _extra: SpotifyHandlerExtra) => {
      const { limit = 10 } = args;
    
      try {
        const queue = await handleSpotifyRequest(async (spotifyApi) => {
          return await spotifyApi.player.getUsersQueue();
        });
    
        const current = (queue as any)?.currently_playing;
        const upcoming = ((queue as any)?.queue ?? []) as any[];
    
        const header = '# Spotify Queue\n\n';
    
        let currentText = 'Nothing is currently playing';
        if (current) {
          const name = current?.name ?? 'Unknown';
          const artists = Array.isArray(current?.artists)
            ? (current.artists as Array<{ name: string }>)
                .map((a) => a.name)
                .join(', ')
            : 'Unknown';
          const duration =
            typeof current?.duration_ms === 'number'
              ? formatDuration(current.duration_ms)
              : 'Unknown';
          currentText = `Currently Playing: "${name}" by ${artists} (${duration})`;
        }
    
        if (upcoming.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: `${header}${currentText}\n\nNo upcoming items in the queue`,
              },
            ],
          };
        }
    
        const toShow = upcoming.slice(0, limit);
        const formatted = toShow
          .map((track, i) => {
            const name = track?.name ?? 'Unknown';
            const artists = Array.isArray(track?.artists)
              ? (track.artists as Array<{ name: string }>)
                  .map((a) => a.name)
                  .join(', ')
              : 'Unknown';
            const duration =
              typeof track?.duration_ms === 'number'
                ? formatDuration(track.duration_ms)
                : 'Unknown';
            const id = track?.id ?? 'Unknown';
            return `${i + 1}. "${name}" by ${artists} (${duration}) - ID: ${id}`;
          })
          .join('\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `${header}${currentText}\n\nNext ${toShow.length} in queue:\n\n${formatted}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching queue: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    },
  • The Zod input schema for the getQueue tool, defining an optional 'limit' parameter between 1 and 50.
    schema: {
      limit: z
        .number()
        .min(1)
        .max(50)
        .optional()
        .describe('Maximum number of upcoming items to show (1-50)'),
    },
  • src/read.ts:531-539 (registration)
    The getQueue tool is registered by being included in the exported readTools array, which collects all read-related Spotify tools for the MCP server.
    export const readTools = [
      searchSpotify,
      getNowPlaying,
      getMyPlaylists,
      getPlaylistTracks,
      getRecentlyPlayed,
      getUsersSavedTracks,
      getQueue,
    ];
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 returns, not behavioral traits like whether it requires active playback, rate limits, authentication needs, or error conditions. It's a basic functional description without operational context.

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?

Single sentence that efficiently communicates the core purpose with zero wasted words. Front-loaded with the main action and immediately specifies the scope. Perfectly sized for this simple tool.

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

Completeness3/5

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

For a simple read operation with 1 parameter and no output schema, the description is minimally adequate but lacks important context about authentication requirements, whether playback must be active, and what happens when there's no queue. With no annotations and no output schema, more behavioral disclosure would be helpful.

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?

Schema description coverage is 100%, so the schema already fully documents the 'limit' parameter. The description doesn't add any parameter semantics beyond what the schema provides (no additional context about default behavior when limit isn't specified, or how the limit applies to queue items).

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

Purpose5/5

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

The description clearly states the specific action ('Get a list') and the exact resources ('currently playing track and the next items in your Spotify queue'). It distinguishes from siblings like 'getNowPlaying' (which only shows current track) and 'getRecentlyPlayed' (historical data).

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

Usage Guidelines3/5

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

The description implies usage context (when you want to see upcoming queue items), but doesn't explicitly state when to use this vs alternatives like 'getNowPlaying' for just current track or 'getRecentlyPlayed' for history. No explicit exclusions or prerequisites are mentioned.

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