searchSongs
Search a streamer's song list by title or artist to find specific tracks for requests or queue management.
Instructions
Search within a streamer's song list by title or artist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| streamerName | No | The name of the streamer whose songs to search | |
| query | Yes | Search query to match against song titles and artists | |
| limit | No | Maximum number of results to return (default: 20) |
Implementation Reference
- src/server.js:435-486 (handler)The handler for the 'searchSongs' tool. Fetches up to 1000 songs from the streamer's song list via API, filters them client-side by checking if the query (lowercased) is contained in the song's title or artist (case-insensitive), limits to the specified number, and returns the results as formatted text.case "searchSongs": { const { streamerName = defaultStreamer, query, limit = 20 } = args; if (!streamerName) { throw new Error( "streamerName is required. Provide a streamerName or set the DEFAULT_STREAMER environment variable." ); } if (!query) { throw new Error("query is required for song search"); } try { // First get all songs, then filter locally const response = await fetch(`${API_BASE}/streamers/${encodeURIComponent(streamerName)}/songs?limit=1000`); if (!response.ok) { return { content: [{ type: "text", text: `Error fetching songs for search: ${response.status} ${response.statusText}` }] }; } const songsData = await response.json(); const allSongs = songsData.items || songsData; // Handle different response formats const searchQuery = query.toLowerCase(); // Filter songs by title or artist const filteredSongs = allSongs.filter(song => { const title = (song.title || '').toLowerCase(); const artist = (song.artist || '').toLowerCase(); return title.includes(searchQuery) || artist.includes(searchQuery); }).slice(0, limit); return { content: [{ type: "text", text: `Found ${filteredSongs.length} songs matching "${query}":\n${JSON.stringify(filteredSongs, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }
- src/server.js:214-236 (schema)The input schema definition for the 'searchSongs' tool, specifying parameters streamerName (optional), query (required string), and limit (optional number, default 20).{ name: "searchSongs", description: "Search within a streamer's song list by title or artist", inputSchema: { type: "object", properties: { streamerName: { type: "string", description: "The name of the streamer whose songs to search", }, query: { type: "string", description: "Search query to match against song titles and artists", }, limit: { type: "number", description: "Maximum number of results to return (default: 20)", default: 20, }, }, required: ["query"], }, },
- src/server.js:258-262 (registration)Registration of the list tools handler, which returns the tools array including 'searchSongs'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; });
- src/index.ts:274-287 (handler)Alternative handler implementation in TypeScript version, directly queries the API with a 'search' parameter assuming server-side search support.case "searchSongs": { const streamerName = getEffectiveStreamer((args as any)?.streamerName); const query = (args as any)?.query; const limit = (args as any)?.limit || 20; const data = await makeApiRequest(`/streamers/${encodeURIComponent(streamerName)}/songs?search=${encodeURIComponent(query)}&limit=${limit}`); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:119-141 (schema)Input schema for 'searchSongs' in the TypeScript index file.{ name: "searchSongs", description: "Search within a streamer's song list by title or artist", inputSchema: { type: "object", properties: { streamerName: { type: "string", description: "The name of the streamer whose songs to search", }, query: { type: "string", description: "Search query to match against song titles and artists", }, limit: { type: "number", description: "Maximum number of results to return (default: 20)", default: 20, }, }, required: ["query"], }, },