get_active_timers
Retrieve currently running sleep timers to monitor when Spotify playback will automatically stop.
Instructions
Get list of active sleep timers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/timer.ts:44-59 (handler)The main handler function implementing the logic for the 'get_active_timers' tool. It fetches active timers, computes remaining time, and formats the response.export async function getActiveTimers(timerManager: TimerManager) { const timers = timerManager.getActiveTimers(); return { success: true, timers: timers.map(timer => { const remaining = timerManager.getRemainingTime(timer.id); return { id: timer.id, durationMinutes: timer.duration, scheduledAt: new Date(timer.scheduledAt).toISOString(), remainingSeconds: remaining, }; }), }; }
- src/server.ts:205-212 (registration)Registration of the tool in the MCP server's tool list, defining name, description, and input schema (no input parameters).{ name: 'get_active_timers', description: 'Get list of active sleep timers', inputSchema: { type: 'object', properties: {}, }, },
- src/server.ts:391-400 (registration)Dispatch logic in the CallToolRequest handler that invokes the tool handler and formats the MCP response.case 'get_active_timers': const timersResult = await timerTools.getActiveTimers(timerManager); return { content: [ { type: 'text', text: JSON.stringify(timersResult, null, 2), }, ], };
- src/timer.ts:62-64 (helper)Core TimerManager method providing the raw list of active SleepTimers, used by the tool handler.getActiveTimers(): SleepTimer[] { return Array.from(this.timers.values()); }
- src/types.ts:13-18 (schema)Type definition for SleepTimer interface used in timer management and tool output.export interface SleepTimer { id: string; duration: number; scheduledAt: number; timeoutId: NodeJS.Timeout; }