Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

spotify_current_playing

Retrieve information about the currently playing song on Spotify, including track details, artist, and playback status.

Instructions

Obtém informações sobre a música que está tocando

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that checks authentication, calls Spotify's getMyCurrentPlayingTrack API, formats the track info (name, artists, album, duration, progress, link), handles no track case, and returns formatted text content or error.
    async getCurrentPlaying() {
      try {
        await this.spotifyAuth.ensureValidToken();
        const spotifyApi = this.spotifyAuth.getSpotifyApi();
    
        const response = await spotifyApi.getMyCurrentPlayingTrack();
        const track = response.body.item;
    
        if (!track) {
          return {
            content: [
              {
                type: 'text',
                text: '❌ Nenhuma música está tocando no momento',
              },
            ],
          };
        }
    
        const artists = track.artists.map((a: any) => a.name).join(', ');
        const duration = Math.floor(track.duration_ms / 60000);
        const durationSeconds = Math.floor((track.duration_ms % 60000) / 1000);
        const progress = Math.floor((response.body.progress_ms || 0) / 60000);
        const progressSeconds = Math.floor(((response.body.progress_ms || 0) % 60000) / 1000);
    
        let content = `🎵 **Música atual:**\n\n`;
        content += `**${track.name}** - ${artists}\n`;
        content += `Álbum: ${track.album.name}\n`;
        content += `Duração: ${duration}:${String(durationSeconds).padStart(2, '0')}\n`;
        content += `Progresso: ${progress}:${String(progressSeconds).padStart(2, '0')}\n`;
        content += `Link: ${track.external_urls.spotify}\n`;
    
        return {
          content: [
            {
              type: 'text',
              text: content,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `❌ Erro ao obter música atual: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • src/index.ts:161-168 (registration)
    Tool registration in the ListToolsRequestHandler response, defining the tool name, description, and empty input schema (no parameters required).
    {
      name: 'spotify_current_playing',
      description: 'Obtém informações sobre a música que está tocando',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • src/index.ts:286-287 (registration)
    Dispatch registration in the CallToolRequestHandler switch statement, routing calls to this tool name to the spotifyTools.getCurrentPlaying() method.
    case 'spotify_current_playing':
      return await spotifyTools.getCurrentPlaying();
  • Input schema definition for the tool: an empty object (no input parameters required).
    inputSchema: {
      type: 'object',
      properties: {},
    },
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 gets information, implying a read-only operation, but doesn't specify what information is returned (e.g., track name, artist, album), whether it requires active playback, error handling (e.g., if nothing is playing), or rate limits. This leaves significant gaps for an agent to understand 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 in Portuguese that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Obtém informações'), making it easy to parse. Every part of the sentence earns its place by conveying essential intent.

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 complexity (simple read operation) but lack of annotations and no output schema, the description is incomplete. It doesn't explain what information is returned (e.g., JSON structure), error conditions, or dependencies like authentication. For a tool that interacts with an external service (Spotify), more context is needed to use it effectively.

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 tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to explain parameters, so it naturally meets the baseline. It doesn't add or detract from parameter understanding, as there are none to document.

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 'Obtém informações sobre a música que está tocando' clearly states the tool's purpose: to get information about the currently playing music. It uses a specific verb ('Obtém') and resource ('música que está tocando'), making the intent unambiguous. However, it doesn't explicitly differentiate from siblings like 'spotify_devices' or 'spotify_playlists', which also provide information but about different resources.

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., requires authentication via 'spotify_auth'), context (e.g., only works if music is actively playing), or exclusions (e.g., not for historical playback data). With siblings like 'spotify_search' for finding tracks, clear usage distinctions are missing.

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