monitorQueue
Monitor song queue changes for streamers with configurable polling intervals to track request updates in real-time.
Instructions
Monitor queue changes with configurable polling intervals
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| streamerName | No | The name of the streamer whose queue to monitor | |
| interval | No | Polling interval in seconds (default: 30) | |
| duration | No | How long to monitor in seconds (default: 300) |
Implementation Reference
- src/server.js:347-395 (handler)Simulation-based handler for the monitorQueue tool. Fetches initial queue state and returns monitoring setup information, noting that real-time updates would require WebSocket/SSE.case "monitorQueue": { const { streamerName = defaultStreamer, interval = 30, duration = 300 } = args; if (!streamerName) { throw new Error( "streamerName is required. Provide a streamerName or set the DEFAULT_STREAMER environment variable." ); } try { const updates = []; // Initial queue fetch const initialResponse = await fetch(`https://api.streamersonglist.com/v1/streamers/${encodeURIComponent(streamerName)}/queue`); if (initialResponse.ok) { const initialQueue = await initialResponse.json(); updates.push({ timestamp: new Date().toISOString(), type: 'initial', data: initialQueue }); } const monitoringId = `monitor_${streamerName}_${Date.now()}`; return { content: [{ type: "text", text: `Started monitoring queue for ${streamerName}\n` + `Monitoring ID: ${monitoringId}\n` + `Interval: ${interval} seconds\n` + `Duration: ${duration} seconds\n` + `\nNote: This is a simulation. In a real implementation, this would:\n` + `- Establish WebSocket or SSE connection\n` + `- Subscribe to queue updates for the streamer\n` + `- Send real-time notifications of queue changes\n` + `\nInitial queue data:\n${JSON.stringify(updates, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error setting up monitoring: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }
- src/index.ts:220-257 (handler)Polling-based implementation of monitorQueue handler that periodically fetches the queue for the specified duration and collects results including timestamps and queue lengths.case "monitorQueue": { const streamerName = getEffectiveStreamer((args as any)?.streamerName); const interval = ((args as any)?.interval || 30) * 1000; // Convert to milliseconds const duration = ((args as any)?.duration || 300) * 1000; // Convert to milliseconds const startTime = Date.now(); const results: any[] = []; while (Date.now() - startTime < duration) { try { const data = await makeApiRequest(`/streamers/${encodeURIComponent(streamerName)}/queue`); results.push({ timestamp: new Date().toISOString(), queueLength: data.list?.length || 0, data: data, }); if (Date.now() - startTime + interval < duration) { await new Promise(resolve => setTimeout(resolve, interval)); } } catch (error: any) { results.push({ timestamp: new Date().toISOString(), error: error.message, }); break; } } return { content: [ { type: "text", text: JSON.stringify(results, null, 2), }, ], }; }
- src/server.js:166-189 (schema)Input schema definition for the monitorQueue tool, specifying parameters for streamerName, interval, and duration.{ name: "monitorQueue", description: "Monitor queue changes with configurable polling intervals", inputSchema: { type: "object", properties: { streamerName: { type: "string", description: "The name of the streamer whose queue to monitor", }, interval: { type: "number", description: "Polling interval in seconds (default: 30)", default: 30, }, duration: { type: "number", description: "How long to monitor in seconds (default: 300)", default: 300, }, }, required: [], }, },
- src/index.ts:71-94 (schema)Input schema for the monitorQueue tool in the TypeScript implementation.{ name: "monitorQueue", description: "Monitor queue changes with configurable polling intervals", inputSchema: { type: "object", properties: { streamerName: { type: "string", description: "The name of the streamer whose queue to monitor", }, interval: { type: "number", description: "Polling interval in seconds (default: 30)", default: 30, }, duration: { type: "number", description: "How long to monitor in seconds (default: 300)", default: 300, }, }, required: [], }, },