Skip to main content
Glama
igorgarbuz

Spotify MCP Node Server

by igorgarbuz

removeTracksFromPlaylist

Remove specific tracks from a Spotify playlist by providing playlist and track IDs. This tool helps users manage playlist content by deleting unwanted songs.

Instructions

Remove tracks from a Spotify playlist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlistIdYesThe Spotify ID of the playlist
trackIdsYesArray of Spotify track IDs to remove

Implementation Reference

  • The async handler function that implements the tool logic: validates input, constructs track URIs, calls Spotify API to remove items from playlist, and returns success/error messages.
    handler: async (args, extra: SpotifyHandlerExtra) => {
      const { playlistId, trackIds } = args;
    
      if (trackIds.length === 0) {
        return {
          content: [
            {
              type: 'text',
              text: 'Error: No track IDs provided',
            },
          ],
        };
      }
    
      try {
        const tracks = trackIds.map((id) => ({
          uri: `spotify:track:${id}`,
        }));
    
        await handleSpotifyRequest(async (spotifyApi) => {
          await spotifyApi.playlists.removeItemsFromPlaylist(playlistId, {
            tracks,
          });
        });
    
        return {
          content: [
            {
              type: 'text',
              text: `Successfully removed ${trackIds.length} track${
                trackIds.length === 1 ? '' : 's'
              } from playlist (ID: ${playlistId})`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error removing tracks from playlist: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    },
  • Zod schema for input validation: requires playlistId (string) and trackIds (array of strings).
    schema: {
      playlistId: z.string().describe('The Spotify ID of the playlist'),
      trackIds: z
        .array(z.string())
        .describe('Array of Spotify track IDs to remove'),
    },
  • src/write.ts:238-243 (registration)
    Includes the removeTracksFromPlaylist tool in the exported writeTools array, which is imported and registered elsewhere.
    export const writeTools = [
      addToQueue,
      addTracksToPlaylist,
      createPlaylist,
      removeTracksFromPlaylist,
    ];
  • src/index.ts:12-14 (registration)
    Registers all tools from playTools, readTools, and writeTools arrays with the MCP server by calling server.tool() for each.
    [...playTools, ...readTools, ...writeTools].forEach((tool) => {
      server.tool(tool.name, tool.description, tool.schema, tool.handler);
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('remove') but doesn't clarify whether this is destructive (permanent removal), requires specific authentication, has rate limits, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's appropriately sized and front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after removal (e.g., confirmation, error handling), authentication requirements, or how it differs from related tools. Given the complexity of modifying user data, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters (playlistId and trackIds). The description adds no additional parameter context beyond what the schema already provides, so it meets the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('remove') and target ('tracks from a Spotify playlist'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'addTracksToPlaylist' or 'playbackAction', which could also involve track manipulation in different contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., user must own or have edit permissions for the playlist), nor does it contrast with sibling tools like 'addTracksToPlaylist' or 'playMusic' that involve track operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/igorgarbuz/spotify-mcp'

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