search_music
Search for tracks, albums, and artists on Spotify using queries to find specific music content.
Instructions
Search for music (tracks, albums, artists) on Spotify
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| limit | No | Maximum number of results per type (default: 10) |
Implementation Reference
- src/tools/search.ts:3-15 (handler)The core handler function for the 'search_music' tool. It searches Spotify using the provided client and query, limits results, and returns formatted tracks, albums, and artists.export async function searchMusic(client: SpotifyClient, query: string, limit: number = 10) { const results = await client.search(query, limit); return { success: true, query, results: { tracks: results.tracks.slice(0, limit), albums: results.albums.slice(0, limit), artists: results.artists.slice(0, limit), }, }; }
- src/server.ts:129-146 (registration)Registration of the 'search_music' tool in the MCP server's ListTools response, including name, description, and input schema definition.{ name: 'search_music', description: 'Search for music (tracks, albums, artists) on Spotify', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, limit: { type: 'number', description: 'Maximum number of results per type (default: 10)', }, }, required: ['query'], }, },
- src/server.ts:321-334 (registration)Dispatch handler in the CallToolRequestSchema that invokes the search_music tool implementation when called.case 'search_music': const searchResult = await searchTools.searchMusic( client, args?.query as string, (args?.limit as number) || 10 ); return { content: [ { type: 'text', text: JSON.stringify(searchResult, null, 2), }, ], };
- src/server.ts:13-13 (registration)Import of the search tools module containing the searchMusic handler.import * as searchTools from './tools/search.js';