createPlaylist
Create a new Spotify playlist with a name, optional description, and privacy settings to organize your music collection.
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:182-203 (handler)The handler function for the 'createPlaylist' tool. It destructures args, gets the current user profile, creates the playlist using spotifyApi.playlists.createPlaylist, and returns a success message with the 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}`, }, ], }; },
- src/play.ts:171-181 (schema)Zod input schema for the 'createPlaylist' tool defining required 'name' string, optional 'description' string, and 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/index.ts:12-14 (registration)Main MCP server registration loop that registers the 'createPlaylist' tool (via playTools) by calling server.tool with its name, description, schema, and handler.[...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });
- src/play.ts:362-371 (registration)Local grouping of play-related tools including 'createPlaylist' in the exported playTools array, which is then registered in index.ts.export const playTools = [ playMusic, pausePlayback, skipToNext, skipToPrevious, createPlaylist, addTracksToPlaylist, resumePlayback, addToQueue, ];