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
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The playback action to perform | |
| deviceId | No | The Spotify device ID to perform the action on |
Implementation Reference
- src/player.ts:92-127 (handler)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, }, ], }; },
- src/player.ts:83-91 (schema)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); });