Skip to main content
Glama
marcelmarais

Spotify MCP Server

by marcelmarais

getNowPlaying

Retrieve details about the currently playing Spotify track, including device and volume information, for real-time playback monitoring.

Instructions

Get information about the currently playing track on Spotify, including device and volume info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Full definition of the getNowPlaying tool, including its name, description, empty input schema, and the handler function that fetches the current Spotify playback state, checks if it's a track, and returns formatted information about the track, device, volume, shuffle, and repeat status.
    const getNowPlaying: tool<Record<string, never>> = {
      name: 'getNowPlaying',
      description:
        'Get information about the currently playing track on Spotify, including device and volume info',
      schema: {},
      handler: async (_args, _extra: SpotifyHandlerExtra) => {
        try {
          const playback = await handleSpotifyRequest(async (spotifyApi) => {
            return await spotifyApi.player.getPlaybackState();
          });
    
          if (!playback?.item) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Nothing is currently playing on Spotify',
                },
              ],
            };
          }
    
          const item = playback.item;
    
          if (!isTrack(item)) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Currently playing item is not a track (might be a podcast episode)',
                },
              ],
            };
          }
    
          const artists = item.artists.map((a) => a.name).join(', ');
          const album = item.album.name;
          const duration = formatDuration(item.duration_ms);
          const progress = formatDuration(playback.progress_ms || 0);
          const isPlaying = playback.is_playing;
    
          const device = playback.device;
          const deviceInfo = device
            ? `${device.name} (${device.type})`
            : 'Unknown device';
          const volume =
            device?.volume_percent !== null && device?.volume_percent !== undefined
              ? `${device.volume_percent}%`
              : 'N/A';
          const shuffle = playback.shuffle_state ? 'On' : 'Off';
          const repeat = playback.repeat_state || 'off';
    
          return {
            content: [
              {
                type: 'text',
                text:
                  `# Currently ${isPlaying ? 'Playing' : 'Paused'}\n\n` +
                  `**Track**: "${item.name}"\n` +
                  `**Artist**: ${artists}\n` +
                  `**Album**: ${album}\n` +
                  `**Progress**: ${progress} / ${duration}\n` +
                  `**ID**: ${item.id}\n\n` +
                  `**Device**: ${deviceInfo}\n` +
                  `**Volume**: ${volume}\n` +
                  `**Shuffle**: ${shuffle} | **Repeat**: ${repeat}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error getting current track: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      },
    };
  • src/read.ts:603-612 (registration)
    Local registration: getNowPlaying is included in the exported readTools array, grouping read-related Spotify tools.
    export const readTools = [
      searchSpotify,
      getNowPlaying,
      getMyPlaylists,
      getPlaylistTracks,
      getRecentlyPlayed,
      getUsersSavedTracks,
      getQueue,
      getAvailableDevices,
    ];
  • src/index.ts:5-14 (registration)
    Main registration: Imports readTools (which includes getNowPlaying) and registers all tools (read, play, album) on the MCP server using server.tool() for each.
    import { readTools } from './read.js';
    
    const server = new McpServer({
      name: 'spotify-controller',
      version: '1.0.0',
    });
    
    [...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 mentions what information is returned but does not cover critical aspects like authentication requirements, rate limits, error conditions, or whether it requires active playback. This leaves significant gaps for a tool interacting with an external service.

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 tool's purpose and key details without redundancy. It is front-loaded with the main action and resource, making it easy to parse quickly.

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?

Given the lack of annotations and output schema, the description provides basic purpose but misses behavioral context like auth needs or error handling. For a tool with no structured metadata, it is minimally adequate but 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.

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately does not discuss parameters, focusing instead on the tool's output scope. This meets the baseline for zero-parameter tools.

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 information') and resource ('currently playing track on Spotify'), distinguishing it from siblings like getQueue or getRecentlyPlayed by focusing on real-time playback status. It explicitly mentions included details ('device and volume info'), making the purpose unambiguous.

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 when checking current playback, but lacks explicit guidance on when to use this tool versus alternatives like getQueue (for upcoming tracks) or getRecentlyPlayed (for past activity). No exclusions or prerequisites are stated, leaving usage context inferred rather than defined.

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