Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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),
          },
        ],
      };
  • Core TimerManager method providing the raw list of active SleepTimers, used by the tool handler.
    getActiveTimers(): SleepTimer[] {
      return Array.from(this.timers.values());
    }
  • Type definition for SleepTimer interface used in timer management and tool output.
    export interface SleepTimer {
      id: string;
      duration: number;
      scheduledAt: number;
      timeoutId: NodeJS.Timeout;
    }

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