Skip to main content
Glama

control_playback

Control Spotify playback by performing actions like play, pause, skip tracks, or adjust volume through the Spotify MCP Server.

Instructions

Control Spotify playback (play, pause, skip, volume)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform
valueNoVolume percentage (0-100) for volume action
deviceIdNoOptional device ID

Implementation Reference

  • Core handler function that executes the control_playback tool logic using SpotifyClient methods for play, pause, skip, and volume control.
    export async function controlPlayback( client: SpotifyClient, action: 'play' | 'pause' | 'skip-next' | 'skip-previous' | 'volume', value?: number, deviceId?: string ) { switch (action) { case 'play': await client.resume(deviceId); return { success: true, message: 'Playback resumed' }; case 'pause': await client.pause(deviceId); return { success: true, message: 'Playback paused' }; case 'skip-next': await client.skipToNext(deviceId); return { success: true, message: 'Skipped to next track' }; case 'skip-previous': await client.skipToPrevious(deviceId); return { success: true, message: 'Skipped to previous track' }; case 'volume': if (value === undefined || value < 0 || value > 100) { throw new Error('Volume must be between 0 and 100'); } await client.setVolume(value, deviceId); return { success: true, message: `Volume set to ${value}%` }; default: throw new Error(`Unknown action: ${action}`); } }
  • Tool specification including name, description, and input schema for the control_playback tool in the MCP ListTools response.
    { name: 'control_playback', description: 'Control Spotify playback (play, pause, skip, volume)', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['play', 'pause', 'skip-next', 'skip-previous', 'volume'], description: 'Action to perform', }, value: { type: 'number', description: 'Volume percentage (0-100) for volume action', }, deviceId: { type: 'string', description: 'Optional device ID', }, }, required: ['action'], }, },
  • src/server.ts:284-298 (registration)
    Dispatch handler in CallToolRequestSchema that invokes the controlPlayback function with parsed arguments.
    case 'control_playback': const controlResult = await playbackTools.controlPlayback( client, args?.action as 'play' | 'pause' | 'skip-next' | 'skip-previous' | 'volume', args?.value as number | undefined, args?.deviceId as string | undefined ); return { content: [ { type: 'text', text: JSON.stringify(controlResult, 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