search_music
Search for tracks, albums, and artists on Spotify to find music using queries and control playback through MCP tools.
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 that executes the search_music tool logic, delegating to SpotifyClient.search and formatting the results.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:116-129 (schema)Input schema definition for the search_music tool in the ListTools response.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:269-282 (registration)Registration of the search_music handler in the MCP server's CallToolRequestHandler switch statement.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), }, ], };