monitorQueue
Monitor a streamer's song request queue for changes. Configure polling interval and monitoring duration to track queue updates.
Instructions
Monitor queue changes with configurable polling intervals
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "monitorQueue"
}
}Input 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/index.ts:220-257 (handler)Handler implementation for the monitorQueue tool. Polls the queue API at a configurable interval for a configurable duration, collecting timestamped snapshots of queue data including queue length. Uses a loop with setTimeout and returns all collected results as JSON.
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/index.ts:72-93 (schema)Input schema definition for monitorQueue: accepts streamerName (string), interval (number, default 30s), and duration (number, default 300s).
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:162-165 (registration)Registration of all tools via ListToolsRequestSchema handler, which returns the tools array including monitorQueue.
// Register tools server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools, })); - src/server.js:347-395 (handler)Alternative JS handler implementation for monitorQueue. Fetches initial queue data once and returns a simulation message indicating that real-time monitoring would use WebSocket/SSE. This is a simplified/simulation version.
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/server.js:166-189 (schema)Input schema definition for monitorQueue in the JS server file. Same schema as index.ts.
{ 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: [], }, },