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
| 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:91-127 (handler)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, }, ], }; },
- src/player.ts:82-90 (schema)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); });