remove_from_playlist
Remove unwanted tracks from Spotify playlists you own or can edit. Clean up outdated songs, delete duplicates, and maintain playlist quality by pruning poor matches.
Instructions
Remove unwanted tracks from any playlist that the user owns or can modify.
🎯 USE CASES: • Clean up playlists by removing outdated or unwanted songs • Maintain playlist quality by pruning poor matches • Remove duplicates and fix playlist organization • Update seasonal playlists by removing irrelevant tracks • Collaborate on playlist refinement with shared editing
📝 WHAT IT RETURNS: • Confirmation of successful track removals • Updated playlist length and duration • New snapshot ID reflecting the changes • List of successfully removed tracks • Error details for tracks that couldn't be removed
🔍 EXAMPLES: • "Remove 'Yesterday' from my Modern Hits playlist" • "Delete these 3 songs from my party playlist" • "Remove track spotify:track:4uLU6hMCjMI75M1A2tKUQC from favorites" • "Clean up duplicate songs from my road trip playlist"
🧹 CLEANING FEATURES: • Remove single tracks or multiple tracks at once • Maintains playlist integrity after removals • Preserves order of remaining tracks • Perfect for playlist maintenance and curation • Supports bulk removals for efficiency
💡 MAINTENANCE TIPS: • Regular cleanup keeps playlists relevant • Remove songs that no longer fit the theme • Check for duplicates and outdated content • Consider seasonal relevance for themed playlists • Use bulk removals for major playlist overhauls
⚠️ REQUIREMENTS: • Valid Spotify access token with playlist-modify scopes • User must own playlist or have collaborative access • Track URIs must match exactly for successful removal
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | Spotify access token for authentication | |
| playlistId | Yes | Spotify playlist ID or URI | |
| trackUris | Yes | Array of Spotify track URIs |
Implementation Reference
- src/mcp/tools/index.ts:22-36 (registration)Registers the remove_from_playlist tool by spreading playlistTools (which contains it) into the main allTools registry used by ToolRegistrar.export const allTools: ToolsRegistry = { ...albumTools, ...artistTools, ...trackTools, ...playlistTools, ...playbackTools, ...userTools, ...searchTools, };
- src/mcp/tools/playlists.ts:272-327 (handler)Defines the MCP tool 'remove_from_playlist' including title, description, input schema, and handler function that delegates to SpotifyService.removeTracksFromPlaylist.remove_from_playlist: { title: "Remove Tracks from Playlist", description: `Remove unwanted tracks from any playlist that the user owns or can modify. 🎯 USE CASES: • Clean up playlists by removing outdated or unwanted songs • Maintain playlist quality by pruning poor matches • Remove duplicates and fix playlist organization • Update seasonal playlists by removing irrelevant tracks • Collaborate on playlist refinement with shared editing 📝 WHAT IT RETURNS: • Confirmation of successful track removals • Updated playlist length and duration • New snapshot ID reflecting the changes • List of successfully removed tracks • Error details for tracks that couldn't be removed 🔍 EXAMPLES: • "Remove 'Yesterday' from my Modern Hits playlist" • "Delete these 3 songs from my party playlist" • "Remove track spotify:track:4uLU6hMCjMI75M1A2tKUQC from favorites" • "Clean up duplicate songs from my road trip playlist" 🧹 CLEANING FEATURES: • Remove single tracks or multiple tracks at once • Maintains playlist integrity after removals • Preserves order of remaining tracks • Perfect for playlist maintenance and curation • Supports bulk removals for efficiency 💡 MAINTENANCE TIPS: • Regular cleanup keeps playlists relevant • Remove songs that no longer fit the theme • Check for duplicates and outdated content • Consider seasonal relevance for themed playlists • Use bulk removals for major playlist overhauls ⚠️ REQUIREMENTS: • Valid Spotify access token with playlist-modify scopes • User must own playlist or have collaborative access • Track URIs must match exactly for successful removal`, schema: createSchema({ token: commonSchemas.token(), playlistId: commonSchemas.spotifyId("playlist"), trackUris: commonSchemas.trackUris(), }), handler: async (args: any, spotifyService: SpotifyService) => { const { token, playlistId, trackUris } = args; return await spotifyService.removeTracksFromPlaylist( token, playlistId, trackUris ); }, },
- src/mcp/tools/playlists.ts:314-318 (schema)Input schema for the remove_from_playlist tool using common schemas for token, playlist ID, and track URIs.schema: createSchema({ token: commonSchemas.token(), playlistId: commonSchemas.spotifyId("playlist"), trackUris: commonSchemas.trackUris(), }),
- src/spotify.ts:567-585 (helper)Core helper function in SpotifyService that performs the actual Spotify API DELETE request to remove tracks from a playlist by constructing the request body with track URIs.async removeTracksFromPlaylist( token: string, playlistId: string, trackUris: string | string[] ): Promise<{ snapshot_id: string }> { const id = this.extractId(playlistId); const data = { tracks: (Array.isArray(trackUris) ? trackUris : [trackUris]).map( (uri) => ({ uri }) ), }; return await this.makeRequest<{ snapshot_id: string }>( `playlists/${id}/tracks`, token, {}, "DELETE", data ); }