Skip to main content
Glama

createPlaylist

Generate a new Spotify playlist by specifying its name, description, and visibility settings.

Instructions

Create a new playlist on Spotify

Input Schema

NameRequiredDescriptionDefault
descriptionNoThe description of the playlist
nameYesThe name of the playlist
publicNoWhether the playlist should be public

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "description": { "description": "The description of the playlist", "type": "string" }, "name": { "description": "The name of the playlist", "type": "string" }, "public": { "description": "Whether the playlist should be public", "type": "boolean" } }, "required": [ "name" ], "type": "object" }

Implementation Reference

  • The handler function that implements the createPlaylist tool logic. It retrieves the current user profile, creates a new playlist using the Spotify API with the provided name, description, and public setting, and returns a success message with the new playlist ID.
    handler: async (args, _extra: SpotifyHandlerExtra) => { const { name, description, public: isPublic = false } = args; const result = await handleSpotifyRequest(async (spotifyApi) => { const me = await spotifyApi.currentUser.profile(); return await spotifyApi.playlists.createPlaylist(me.id, { name, description, public: isPublic, }); }); return { content: [ { type: 'text', text: `Successfully created playlist "${name}"\nPlaylist ID: ${result.id}`, }, ], }; },
  • The schema definition for the createPlaylist tool, specifying input parameters: name (required string), description (optional string), and public (optional boolean).
    name: 'createPlaylist', description: 'Create a new playlist on Spotify', schema: { name: z.string().describe('The name of the playlist'), description: z .string() .optional() .describe('The description of the playlist'), public: z .boolean() .optional() .describe('Whether the playlist should be public'), },
  • src/play.ts:362-371 (registration)
    The createPlaylist tool is included in the exported playTools array, which collects playback-related tools for registration.
    export const playTools = [ playMusic, pausePlayback, skipToNext, skipToPrevious, createPlaylist, addTracksToPlaylist, resumePlayback, addToQueue, ];
  • src/index.ts:12-14 (registration)
    The playTools array (including createPlaylist) is spread and each tool is registered with the MCP server using server.tool().
    [...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });

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

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