getSongs
Fetch a streamer's complete song list with pagination support to manage and display music requests during live broadcasts.
Instructions
Fetch the complete song list for a streamer with pagination support
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| streamerName | No | The name of the streamer whose song list to fetch | |
| limit | No | Maximum number of songs to return (default: 100) | |
| offset | No | Number of songs to skip for pagination (default: 0) |
Implementation Reference
- src/index.ts:259-272 (handler)The core handler logic for the 'getSongs' tool. It extracts parameters (streamerName, limit, offset), calls the API endpoint `/streamers/{streamerName}/songs?limit={limit}&offset={offset}`, and returns the JSON response as text content.case "getSongs": { const streamerName = getEffectiveStreamer((args as any)?.streamerName); const limit = (args as any)?.limit || 100; const offset = (args as any)?.offset || 0; const data = await makeApiRequest(`/streamers/${encodeURIComponent(streamerName)}/songs?limit=${limit}&offset=${offset}`); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:95-118 (registration)Tool registration entry in the tools array used for ListToolsRequestSchema, including name, description, and input schema definition.{ name: "getSongs", description: "Fetch the complete song list for a streamer with pagination support", inputSchema: { type: "object", properties: { streamerName: { type: "string", description: "The name of the streamer whose song list to fetch", }, limit: { type: "number", description: "Maximum number of songs to return (default: 100)", default: 100, }, offset: { type: "number", description: "Number of songs to skip for pagination (default: 0)", default: 0, }, }, required: [], }, },
- src/index.ts:98-117 (schema)JSON schema for 'getSongs' tool inputs, defining optional parameters for streamerName, limit, and offset.inputSchema: { type: "object", properties: { streamerName: { type: "string", description: "The name of the streamer whose song list to fetch", }, limit: { type: "number", description: "Maximum number of songs to return (default: 100)", default: 100, }, offset: { type: "number", description: "Number of songs to skip for pagination (default: 0)", default: 0, }, }, required: [], },
- src/index.ts:175-184 (helper)Helper function used by getSongs (and other tools) to make authenticated API requests to the StreamerSongList service.async function makeApiRequest(endpoint: string) { const url = `${apiBase}${endpoint}`; const response = await fetch(url); if (!response.ok) { throw new Error(`API request failed: ${response.status} ${response.statusText}`); } return response.json(); }
- src/index.ts:168-172 (helper)Helper function to resolve streamerName parameter, falling back to config default.function getEffectiveStreamer(requestedStreamer?: string): string { if (requestedStreamer) return requestedStreamer; if (defaultStreamer) return defaultStreamer; throw new Error("No streamer specified and no default streamer configured"); }