Skip to main content
Glama

set_sleep_timer

Automatically pause Spotify playback after a specified duration by setting a sleep timer. Use this tool to stop music or podcasts at a predetermined time.

Instructions

Set a sleep timer to automatically pause playback after specified minutes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
durationMinutesYesDuration in minutes before pausing playback

Implementation Reference

  • The core handler function that implements the set_sleep_timer tool logic. It validates the duration, sets a timer using TimerManager, and returns success details including timer ID.
    export async function setSleepTimer(timerManager: TimerManager, durationMinutes: number) { if (durationMinutes <= 0) { throw new Error('Duration must be greater than 0'); } const timerId = timerManager.setTimer(durationMinutes); const timer = timerManager.getTimer(timerId); if (!timer) { throw new Error('Failed to create timer'); } return { success: true, message: `Sleep timer set for ${durationMinutes} minute(s)`, timerId, durationMinutes, scheduledAt: new Date(timer.scheduledAt).toISOString(), }; }
  • The schema definition for the set_sleep_timer tool, including name, description, and input schema specifying durationMinutes as required number.
    name: 'set_sleep_timer', description: 'Set a sleep timer to automatically pause playback after specified minutes', inputSchema: { type: 'object', properties: { durationMinutes: { type: 'number', description: 'Duration in minutes before pausing playback', }, }, required: ['durationMinutes'], }, },
  • src/server.ts:363-375 (registration)
    The registration and dispatch logic in the MCP CallToolRequestSchema handler that routes calls to set_sleep_timer to the timerTools.setSleepTimer function.
    case 'set_sleep_timer': const timerResult = await timerTools.setSleepTimer( timerManager, args?.durationMinutes as number ); return { content: [ { type: 'text', text: JSON.stringify(timerResult, null, 2), }, ], };

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