searchSongs
Search and filter songs by title, artist, or genre with customizable limits and pagination to manage song requests effectively on streaming platforms.
Instructions
Search the song database with various filters and criteria
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| artist | No | Filter by specific artist name | |
| genre | No | Filter by music genre | |
| limit | No | Maximum number of songs to return (default: 50) | |
| offset | No | Number of songs to skip for pagination (default: 0) | |
| query | No | Search query for song title or artist |
Implementation Reference
- src/index.ts:274-287 (handler)Handler function for the 'searchSongs' tool. Fetches search results from the StreamerSongList API using a search query parameter on the songs endpoint.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 and metadata for the 'searchSongs' tool, defining parameters like streamerName, query (required), and limit.{ 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:435-486 (handler)Alternative handler for 'searchSongs' in the standalone server.js implementation. Fetches a large song list and performs client-side filtering by title or artist.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)Input schema and metadata for the 'searchSongs' tool in server.js, matching the TypeScript version.{ 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"], }, },