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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the playlist | |
| description | No | The description of the playlist | |
| public | No | Whether the playlist should be public |
Implementation Reference
- src/play.ts:164-204 (handler)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); });