Skip to main content
Glama
marcelmarais

Spotify MCP Server

by marcelmarais

getQueue

Retrieve the currently playing track and upcoming items in your Spotify queue to manage playback order and preview upcoming music.

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 for 'getQueue' tool. It fetches the user's Spotify queue using `spotifyApi.player.getUsersQueue()`, formats the currently playing track (if any) and the next up to 'limit' (default 10) items in the queue, handling errors and returning formatted text content.
    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)
              }`,
            },
          ],
        };
      }
    },
  • Input schema for 'getQueue' tool using Zod: optional 'limit' number 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:603-612 (registration)
    Registration of 'getQueue' tool in the exported 'readTools' array, likely used to register all read-related tools in the MCP server.
    export const readTools = [
      searchSpotify,
      getNowPlaying,
      getMyPlaylists,
      getPlaylistTracks,
      getRecentlyPlayed,
      getUsersSavedTracks,
      getQueue,
      getAvailableDevices,
    ];
  • Complete tool definition for 'getQueue', including type annotation, name, description, schema, and handler.
    const getQueue: tool<{
      limit: z.ZodOptional<z.ZodNumber>;
    }> = {
      name: 'getQueue',
      description:
        'Get a list of the currently playing track and the next items in your Spotify queue',
      schema: {
        limit: z
          .number()
          .min(1)
          .max(50)
          .optional()
          .describe('Maximum number of upcoming items to show (1-50)'),
      },
      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)
                }`,
              },
            ],
          };
        }
      },
    };
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 the tool retrieves a list but doesn't describe key behaviors: whether it requires authentication, if it works only with an active playback session, potential rate limits, error conditions (e.g., no queue available), or the format of the returned list (e.g., JSON structure). This leaves significant gaps in understanding how the tool behaves in practice.

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, well-structured sentence that efficiently conveys the core functionality: 'Get a list of the currently playing track and the next items in your Spotify queue.' It is front-loaded with the main action and resource, with no unnecessary words or redundant information, making it highly concise and easy to understand at a glance.

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 tool's moderate complexity (retrieving a dynamic queue with one optional parameter), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like authentication needs, session dependencies, error handling, or return format details. While the schema handles the parameter well, the overall context for safe and effective use is insufficient, especially for a tool that likely interacts with user-specific Spotify data.

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, with the 'limit' parameter fully documented in the schema (type, range, and description). The tool description doesn't add any parameter-specific information beyond what the schema provides, such as default values or usage examples. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract from the schema's documentation.

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 tool's purpose: 'Get a list of the currently playing track and the next items in your Spotify queue.' It specifies the verb ('Get') and resource ('currently playing track and the next items in your Spotify queue'), making the action clear. However, it doesn't explicitly distinguish this tool from sibling tools like 'getNowPlaying' (which might only show the current track) or 'getRecentlyPlayed' (which shows past tracks), leaving some ambiguity in sibling differentiation.

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. It doesn't mention prerequisites (e.g., needing an active Spotify session), exclusions (e.g., not applicable if no music is playing), or comparisons to siblings like 'getNowPlaying' (for current track only) or 'getRecentlyPlayed' (for past tracks). Without such context, users might struggle to choose the right tool in different scenarios.

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