save_playlist
Save user-created Spotify playlists to your library for offline access or organization. Follow collaborative or community playlists with confirmation, updated status, and playlist URL provided.
Instructions
Save a user-created playlist to your Spotify library (follow playlist).
🎯 USE CASES: • Add user-created playlists to your library for offline access • Follow collaborative playlists from friends • Organize personal playlists into collections • Follow community-created playlists
📝 WHAT IT RETURNS: • Confirmation of successful playlist save/follow • Updated library status • Playlist URL for easy sharing and access • Error details for any failed saves
🔍 EXAMPLES: • "Save this collaborative playlist my friend created" • "Follow this user-generated workout playlist" • "Add this personal playlist to my library"
💡 SAVE FEATURES: • Works with user-created playlists • Maintains playlist order and structure • Perfect for following collaborative playlists • Enables offline access to followed playlists
🚫 LIMITATIONS (as of November 27, 2024): • Cannot save Spotify's official/editorial playlists • Cannot follow algorithmic playlists (Discover Weekly, etc.) • Only works with playlists created by users • Spotify-owned playlists are restricted
🔧 TROUBLESHOOTING: • If you get 404 error: The playlist might be Spotify-owned • Try with user-created playlists instead • Check if playlist is public and accessible
⚠️ REQUIREMENTS: • Valid Spotify access token with playlist-modify-public scope • Playlist must be user-created (not Spotify-owned) • Playlist must be public or accessible to your account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlistId | Yes | Spotify playlist ID or URI | |
| token | Yes | Spotify access token for authentication |
Implementation Reference
- src/mcp/tools/playlists.ts:485-488 (handler)MCP tool handler for 'save_playlist' that destructures input arguments and invokes the SpotifyService.savePlaylist method.handler: async (args: any, spotifyService: SpotifyService) => { const { token, playlistId } = args; return await spotifyService.savePlaylist(token, playlistId); },
- src/mcp/tools/playlists.ts:481-484 (schema)Zod-based input schema definition for the 'save_playlist' tool, requiring Spotify token and playlist ID.schema: createSchema({ token: commonSchemas.token(), playlistId: commonSchemas.spotifyId("playlist"), }),
- src/spotify.ts:737-745 (helper)SpotifyService helper method implementing the core logic: extracts playlist ID and makes PUT request to Spotify API endpoint /playlists/{id}/followers to save (follow) the playlist.async savePlaylist(token: string, playlistId: string): Promise<void> { const id = this.extractId(playlistId); return await this.makeRequest<void>( `playlists/${id}/followers`, token, {}, "PUT" ); }
- src/mcp/tools/index.ts:22-36 (registration)Registration of 'save_playlist' tool by spreading playlistTools into the central allTools registry used by ToolRegistrar and MCP server.export const allTools: ToolsRegistry = { ...albumTools, ...artistTools, ...trackTools, ...playlistTools, ...playbackTools, ...userTools, ...searchTools, };
- src/mcp/server.ts:49-80 (registration)MCP server request handler for calling any tool dynamically, including 'save_playlist', using ToolRegistrar to create and invoke the specific tool handler.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const toolHandler = toolRegistrar.createToolHandler(name); const result = await toolHandler(args || {}); return { content: [ { type: "text", text: typeof result === "string" ? result : JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error executing tool '${name}': ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } });