createPlaylist
Create a new playlist on Spotify by specifying its name, description, and privacy settings. This tool enables AI assistants to organize music collections directly through the Spotify MCP Node 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/write.ts:25-46 (handler)The handler function that creates a Spotify playlist for the current user using the provided name, optional description, and public flag. It uses handleSpotifyRequest utility 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}`, }, ], }; },
- src/write.ts:12-24 (schema)Tool name, description, and Zod input schema defining required 'name' (string) and optional 'description' (string), 'public' (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/write.ts:238-243 (registration)The createPlaylist tool is included in the exported writeTools array alongside other write operations.export const writeTools = [ addToQueue, addTracksToPlaylist, createPlaylist, removeTracksFromPlaylist, ];
- src/index.ts:12-14 (registration)All tools from playTools, readTools, and writeTools (including createPlaylist) are registered with the MCP server by calling server.tool() for each.[...playTools, ...readTools, ...writeTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });