Skip to main content
Glama
superseoworld

MCP Spotify Server

get_track

Retrieve detailed Spotify catalog information for a specific track using its ID or URI, providing metadata like artist, album, and duration.

Instructions

Get Spotify catalog information for a track

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe Spotify ID or URI for the track

Implementation Reference

  • The core handler function that executes the 'get_track' tool logic: extracts the track ID from URI if needed and fetches the track details from Spotify API.
    async getTrack(args: TrackArgs) {
      const trackId = this.extractTrackId(args.id);
      return this.api.makeRequest(`/tracks/${trackId}`);
    }
  • TypeScript interface defining the input schema for the 'get_track' tool: requires a track ID or URI.
    export interface TrackArgs {
      id: string;
    }
  • src/index.ts:295-308 (registration)
    Registers the 'get_track' tool in the MCP server's listTools response, including name, description, and input schema.
    {
      name: 'get_track',
      description: 'Get Spotify catalog information for a track',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description: 'The Spotify ID or URI for the track'
          }
        },
        required: ['id']
      },
    },
  • src/index.ts:774-780 (registration)
    Handles incoming calls to the 'get_track' tool in the MCP server's CallToolRequestSchema by validating args and delegating to TracksHandler.getTrack.
    case 'get_track': {
      const args = this.validateArgs<TrackArgs>(request.params.arguments, ['id']);
      const result = await this.tracksHandler.getTrack(args);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Helper method used by getTrack to normalize track IDs from Spotify URIs to plain IDs.
    private extractTrackId(id: string): string {
      return id.startsWith('spotify:track:') ? id.split(':')[2] : id;
    }

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/superseoworld/mcp-spotify'

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