add_tracks_to_playlist
Use this tool to add multiple tracks to a Spotify playlist by specifying their URIs. Simplify playlist management within the Multi-MCPs MCP server environment.
Instructions
Add tracks to a playlist by URIs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_id | Yes | ||
| tracks | Yes |
Implementation Reference
- src/apis/spotify/spotify.ts:138-144 (handler)The main MCP tool handler function for 'add_tracks_to_playlist'. It validates the input arguments (playlist_id and tracks), checks configuration, and delegates to the SpotifyClient's addTracksToPlaylist method.async add_tracks_to_playlist(args: Record<string, unknown>) { if (!cfg.spotifyClientId || !cfg.spotifyClientSecret) throw new Error("SPOTIFY_CLIENT_ID/SECRET are not configured"); const playlistId = String(args.playlist_id || ""); const tracks = Array.isArray(args.tracks) ? (args.tracks as string[]) : []; if (!playlistId || tracks.length === 0) throw new Error("playlist_id and tracks are required"); return client.addTracksToPlaylist(playlistId, tracks); },
- src/apis/spotify/spotify.ts:107-115 (registration)The tool registration entry in the Spotify API module, defining the tool name, description, and input schema.{ name: "add_tracks_to_playlist", description: "Add tracks to a playlist by URIs", inputSchema: { type: "object", properties: { playlist_id: { type: "string" }, tracks: { type: "array", items: { type: "string" } } }, required: ["playlist_id", "tracks"], }, },
- src/apis/spotify/spotify.ts:110-114 (schema)Input schema definition for the 'add_tracks_to_playlist' tool, specifying playlist_id as string and tracks as array of strings.inputSchema: { type: "object", properties: { playlist_id: { type: "string" }, tracks: { type: "array", items: { type: "string" } } }, required: ["playlist_id", "tracks"], },
- src/apis/spotify/spotify.ts:65-71 (helper)Helper method in SpotifyClient class that makes the actual Spotify API request to add track URIs to a playlist.async addTracksToPlaylist(playlistId: string, tracks: string[]) { return this.request(`/playlists/${playlistId}/tracks`, { method: "POST", headers: await this.authHeaders(), body: { uris: tracks }, }); }