play-track
Play a selected Spotify track on your active or specified device using track ID. Control playback directly through the MCP Claude Spotify integration for streamlined music management.
Instructions
Play a specific track on an active device
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | No | Spotify ID of the device to play on (optional) | |
| trackId | Yes | Spotify ID of the track to play |
Input Schema (JSON Schema)
{
"properties": {
"deviceId": {
"description": "Spotify ID of the device to play on (optional)",
"type": "string"
},
"trackId": {
"description": "Spotify ID of the track to play",
"type": "string"
}
},
"required": [
"trackId"
],
"type": "object"
}
Implementation Reference
- index.ts:1146-1163 (handler)The handler logic for the 'play-track' tool. It validates input using PlayTrackSchema, determines the playback endpoint (with optional device_id), sends a PUT request to Spotify API to play the specified track URI, and returns a success message.if (name === "play-track") { const { trackId, deviceId } = PlayTrackSchema.parse(args); const endpoint = deviceId ? `/me/player/play?device_id=${deviceId}` : "/me/player/play"; await spotifyApiRequest(endpoint, "PUT", { uris: [`spotify:track:${trackId}`], }); return { content: [ { type: "text", text: `Started playing track with ID: ${trackId}`, }, ], }; }
- index.ts:177-180 (schema)Zod schema definition for validating the input parameters of the 'play-track' tool: required trackId (string) and optional deviceId (string). Used in the handler for parsing arguments.const PlayTrackSchema = z.object({ trackId: z.string(), deviceId: z.string().optional(), });
- index.ts:671-687 (registration)Tool registration in the ListTools response, defining the 'play-track' tool's name, description, and input schema matching the Zod schema.name: "play-track", description: "Play a specific track on an active device", inputSchema: { type: "object", properties: { trackId: { type: "string", description: "Spotify ID of the track to play", }, deviceId: { type: "string", description: "Spotify ID of the device to play on (optional)", }, }, required: ["trackId"], }, },