Skip to main content
Glama

add-tracks-to-playlist

Add multiple tracks to a Spotify playlist using their track IDs. Specify the playlist ID and track IDs to update your playlist directly through the MCP Claude Spotify integration.

Instructions

Add tracks to a playlist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlistIdYesSpotify ID of the playlist
trackIdsYesArray of Spotify track IDs to add

Implementation Reference

  • Handler function that validates input using AddTracksSchema, constructs track URIs, calls spotifyApiRequest to POST to /playlists/{playlistId}/tracks, and returns success message.
    if (name === "add-tracks-to-playlist") {
      const { playlistId, trackIds } = AddTracksSchema.parse(args);
      
      const uris = trackIds.map((id) => `spotify:track:${id}`);
      
      await spotifyApiRequest(
        `/playlists/${playlistId}/tracks`,
        "POST",
        {
          uris,
        }
      );
      
      return {
        content: [
          {
            type: "text",
            text: `Added ${trackIds.length} tracks to playlist with ID: ${playlistId}`,
          },
        ],
      };
    }
  • Zod validation schema for tool inputs: playlistId (string) and trackIds (array of strings).
    const AddTracksSchema = z.object({
      playlistId: z.string(),
      trackIds: z.array(z.string()),
    });
  • index.ts:751-771 (registration)
    Tool registration in ListTools handler, defining name, description, and input schema matching the Zod schema.
    {
      name: "add-tracks-to-playlist",
      description: "Add tracks to a playlist",
      inputSchema: {
        type: "object",
        properties: {
          playlistId: {
            type: "string",
            description: "Spotify ID of the playlist",
          },
          trackIds: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Array of Spotify track IDs to add",
          },
        },
        required: ["playlistId", "trackIds"],
      },
    },
Install Server

Other Tools

Related 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/imprvhub/mcp-claude-spotify'

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