Skip to main content
Glama
igorgarbuz
by igorgarbuz

createPlaylist

Create a new Spotify playlist with custom name, description, and privacy settings to organize your music collection.

Instructions

Create a new playlist on Spotify

Input Schema

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

Implementation Reference

  • The handler function that destructures arguments, fetches current user profile, creates the playlist via Spotify API, and returns success message with 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}`, }, ], }; },
  • Zod schema defining input parameters for createPlaylist: required name (string), optional description (string), optional public (boolean).
    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/write.ts:238-243 (registration)
    Local registration of createPlaylist tool within the writeTools export array, which is later imported and registered.
    export const writeTools = [ addToQueue, addTracksToPlaylist, createPlaylist, removeTracksFromPlaylist, ];
  • src/index.ts:12-14 (registration)
    Main MCP server tool registration loop that registers all tools, including createPlaylist from writeTools, by calling server.tool() with name, description, schema, and handler.
    [...playTools, ...readTools, ...writeTools].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/igorgarbuz/spotify-mcp'

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