Skip to main content
Glama
igorgarbuz
by igorgarbuz

playbackAction

Control Spotify playback by pausing, resuming, or skipping tracks through the Spotify MCP Node Server. Manage music playback actions with specific device targeting.

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

  • Handler function for the playbackAction tool that performs the specified playback control action (pause, resume, skip next/previous) on Spotify.
    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 for playbackAction tool defining 'action' (required enum) and optional 'deviceId'.
    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)
    playbackAction is added to playTools array for export and subsequent registration.
    export const playTools = [playMusic, playbackAction];
  • src/index.ts:12-14 (registration)
    playTools (including playbackAction) are registered with the MCP server via server.tool calls.
    [...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