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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The Spotify ID or URI for the track |
Implementation Reference
- src/handlers/tracks.ts:15-18 (handler)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}`); }
- src/types/tracks.ts:1-3 (schema)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) }], }; }
- src/handlers/tracks.ts:11-13 (helper)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; }