Skip to main content
Glama
igorgarbuz
by igorgarbuz

playbackAction

Control Spotify playback by pausing, resuming, or skipping tracks using this MCP server tool. Manage music playback actions through the Spotify API.

Instructions

Perform a playback action (pause, resume, skip to next, skip to previous)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe playback action to perform
deviceIdNoThe Spotify device ID to perform the action on

Implementation Reference

  • The handler function executes the playback action by calling the appropriate Spotify API method based on the 'action' parameter (pause, resume, skipToNext, skipToPrevious) on the specified or default device.
    }, handler: async (args, extra: SpotifyHandlerExtra) => { const { action, deviceId } = args; let successMessage = ''; await handleSpotifyRequest(async (spotifyApi) => { const device = deviceId || ''; switch (action) { case 'pause': await spotifyApi.player.pausePlayback(device); successMessage = 'Playback paused'; break; case 'resume': await spotifyApi.player.startResumePlayback(device); successMessage = 'Playback resumed'; break; case 'skipToNext': await spotifyApi.player.skipToNext(device); successMessage = 'Skipped to next track'; break; case 'skipToPrevious': await spotifyApi.player.skipToPrevious(device); successMessage = 'Skipped to previous track'; break; } }); return { content: [ { type: 'text', text: successMessage, }, ], }; },
  • Zod input schema defining 'action' as a required enum and optional 'deviceId' string.
    'Perform a playback action (pause, resume, skip to next, skip to previous)', schema: { action: z .enum(['pause', 'skipToNext', 'skipToPrevious', 'resume']) .describe('The playback action to perform'), deviceId: z .string() .optional() .describe('The Spotify device ID to perform the action on'),
  • src/player.ts:130-130 (registration)
    The playbackAction tool is included in the playTools export array, grouping it with playMusic for later registration.
    export const playTools = [playMusic, playbackAction];
  • src/index.ts:12-14 (registration)
    Tools from playTools (including playbackAction) are registered to the MCP server via server.tool().
    [...playTools, ...readTools, ...writeTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });

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/igorgarbuz/spotify-mcp'

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