add-tracks-to-playlist
Add multiple tracks to a Spotify playlist using their track IDs. Specify the playlist ID and track IDs to update your playlist directly through the MCP Claude Spotify integration.
Instructions
Add tracks to a playlist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlistId | Yes | Spotify ID of the playlist | |
| trackIds | Yes | Array of Spotify track IDs to add |
Implementation Reference
- index.ts:1282-1303 (handler)Handler function that validates input using AddTracksSchema, constructs track URIs, calls spotifyApiRequest to POST to /playlists/{playlistId}/tracks, and returns success message.if (name === "add-tracks-to-playlist") { const { playlistId, trackIds } = AddTracksSchema.parse(args); const uris = trackIds.map((id) => `spotify:track:${id}`); await spotifyApiRequest( `/playlists/${playlistId}/tracks`, "POST", { uris, } ); return { content: [ { type: "text", text: `Added ${trackIds.length} tracks to playlist with ID: ${playlistId}`, }, ], }; }
- index.ts:188-191 (schema)Zod validation schema for tool inputs: playlistId (string) and trackIds (array of strings).const AddTracksSchema = z.object({ playlistId: z.string(), trackIds: z.array(z.string()), });
- index.ts:751-771 (registration)Tool registration in ListTools handler, defining name, description, and input schema matching the Zod schema.{ name: "add-tracks-to-playlist", description: "Add tracks to a playlist", inputSchema: { type: "object", properties: { playlistId: { type: "string", description: "Spotify ID of the playlist", }, trackIds: { type: "array", items: { type: "string", }, description: "Array of Spotify track IDs to add", }, }, required: ["playlistId", "trackIds"], }, },