Skip to main content
Glama

add_tracks_to_playlist

Use this tool to add multiple tracks to a Spotify playlist by specifying their URIs. Simplify playlist management within the Multi-MCPs MCP server environment.

Instructions

Add tracks to a playlist by URIs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_idYes
tracksYes

Implementation Reference

  • The main MCP tool handler function for 'add_tracks_to_playlist'. It validates the input arguments (playlist_id and tracks), checks configuration, and delegates to the SpotifyClient's addTracksToPlaylist method.
    async add_tracks_to_playlist(args: Record<string, unknown>) { if (!cfg.spotifyClientId || !cfg.spotifyClientSecret) throw new Error("SPOTIFY_CLIENT_ID/SECRET are not configured"); const playlistId = String(args.playlist_id || ""); const tracks = Array.isArray(args.tracks) ? (args.tracks as string[]) : []; if (!playlistId || tracks.length === 0) throw new Error("playlist_id and tracks are required"); return client.addTracksToPlaylist(playlistId, tracks); },
  • The tool registration entry in the Spotify API module, defining the tool name, description, and input schema.
    { name: "add_tracks_to_playlist", description: "Add tracks to a playlist by URIs", inputSchema: { type: "object", properties: { playlist_id: { type: "string" }, tracks: { type: "array", items: { type: "string" } } }, required: ["playlist_id", "tracks"], }, },
  • Input schema definition for the 'add_tracks_to_playlist' tool, specifying playlist_id as string and tracks as array of strings.
    inputSchema: { type: "object", properties: { playlist_id: { type: "string" }, tracks: { type: "array", items: { type: "string" } } }, required: ["playlist_id", "tracks"], },
  • Helper method in SpotifyClient class that makes the actual Spotify API request to add track URIs to a playlist.
    async addTracksToPlaylist(playlistId: string, tracks: string[]) { return this.request(`/playlists/${playlistId}/tracks`, { method: "POST", headers: await this.authHeaders(), body: { uris: tracks }, }); }

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/TaylorChen/muti-mcps'

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