Skip to main content
Glama

get_active_timers

Retrieve currently running sleep timers from Spotify to monitor when playback will automatically stop.

Instructions

Get list of active sleep timers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'get_active_timers' tool. It retrieves active timers from the TimerManager, calculates remaining time for each, and returns a formatted response with success flag and timer details.
    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:189-196 (registration)
    Tool registration entry in the ListToolsRequest handler. Defines the tool name, description, and input schema (empty object, no parameters required).
    { name: 'get_active_timers', description: 'Get list of active sleep timers', inputSchema: { type: 'object', properties: {}, }, },
  • src/server.ts:339-348 (registration)
    Dispatch handler in the CallToolRequestSchema handler that maps the tool name to the actual implementation by calling timerTools.getActiveTimers and formatting the response.
    case 'get_active_timers': const timersResult = await timerTools.getActiveTimers(timerManager); return { content: [ { type: 'text', text: JSON.stringify(timersResult, null, 2), }, ], };
  • TimerManager method that returns the list of active SleepTimer objects, used by the tool handler.
    getActiveTimers(): SleepTimer[] { return Array.from(this.timers.values()); }
  • TimerManager helper method to calculate remaining seconds for a timer, used in the tool handler to enrich timer data.
    getRemainingTime(timerId: string): number | null { const timer = this.timers.get(timerId); if (!timer) { return null; } const elapsed = Date.now() - timer.scheduledAt; const remaining = (timer.duration * 60 * 1000) - elapsed; return Math.max(0, Math.floor(remaining / 1000)); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ackberry/spotify_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server