Skip to main content
Glama
superseoworld

MCP Spotify Server

remove_tracks_from_playlist

Delete specific tracks from a Spotify playlist using track URIs to manage and update your music collection.

Instructions

Remove one or more tracks from a playlist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe Spotify ID or URI of the playlist
tracksYesArray of objects containing Spotify track URIs to remove
snapshot_idNoOptional. The playlist's snapshot ID

Implementation Reference

  • The core handler function in PlaylistsHandler class that implements the logic to remove tracks from a Spotify playlist. It extracts the playlist ID, prepares the request data, and makes a DELETE request to the Spotify API endpoint `/playlists/{playlistId}/tracks`.
    async removeTracksFromPlaylist(args: RemoveTracksFromPlaylistArgs) {
      const playlistId = this.extractPlaylistId(args.id);
      const { tracks, snapshot_id } = args;
    
      const data = {
        tracks,
        ...(snapshot_id !== undefined && { snapshot_id })
      };
    
      return this.api.makeRequest(
        `/playlists/${playlistId}/tracks`,
        'DELETE',
        data
      );
    }
  • src/index.ts:582-619 (registration)
    The tool registration in the listTools response, defining the name, description, and inputSchema for 'remove_tracks_from_playlist'.
      name: 'remove_tracks_from_playlist',
      description: 'Remove one or more tracks from a playlist',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description: 'The Spotify ID or URI of the playlist'
          },
          tracks: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                uri: {
                  type: 'string',
                  description: 'Spotify URI of the track to remove'
                },
                positions: {
                  type: 'array',
                  items: {
                    type: 'number'
                  },
                  description: 'Optional positions of the track to remove'
                }
              },
              required: ['uri']
            },
            description: 'Array of objects containing Spotify track URIs to remove'
          },
          snapshot_id: {
            type: 'string',
            description: 'Optional. The playlist\'s snapshot ID'
          }
        },
        required: ['id', 'tracks']
      },
    },
  • TypeScript interface defining the input arguments for the removeTracksFromPlaylist tool, used for validation.
    export interface RemoveTracksFromPlaylistArgs {
      id: string;
      tracks: Array<{
        uri: string;
        positions?: number[];
      }>;
      snapshot_id?: string;
    }
  • src/index.ts:869-875 (registration)
    The dispatch case in the main CallToolRequest handler that validates arguments and delegates to the playlistsHandler.removeTracksFromPlaylist method.
    case 'remove_tracks_from_playlist': {
      const args = this.validateArgs<RemoveTracksFromPlaylistArgs>(request.params.arguments, ['id', 'tracks']);
      const result = await this.playlistsHandler.removeTracksFromPlaylist(args);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/superseoworld/mcp-spotify'

If you have feedback or need assistance with the MCP directory API, please join our Discord server