Skip to main content
Glama

createPlaylist

Create a new playlist on Spotify with a custom name, description, and privacy settings using the Spotify MCP Server.

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 complete tool definition for 'createPlaylist', including its Zod schema and async handler function that creates a new Spotify playlist using the spotifyApi.
    const createPlaylist: tool<{ name: z.ZodString; description: z.ZodOptional<z.ZodString>; public: z.ZodOptional<z.ZodBoolean>; }> = { 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'), }, 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}\nPlaylist URL: ${result.external_urls.spotify}`, }, ], }; }, };
  • src/play.ts:499-510 (registration)
    The 'createPlaylist' tool is included in the exported 'playTools' array, which collects Spotify playback-related tools.
    export const playTools = [ playMusic, pausePlayback, skipToNext, skipToPrevious, createPlaylist, addTracksToPlaylist, resumePlayback, addToQueue, setVolume, adjustVolume, ];
  • src/index.ts:12-14 (registration)
    Tools from 'playTools' (including 'createPlaylist') are registered on the MCP server by calling server.tool() for each tool in the array.
    [...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