createPlaylist
Generate a new Spotify playlist by specifying its name, description, and visibility settings.
Instructions
Create a new playlist on Spotify
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | The description of the playlist | |
| name | Yes | The name of the playlist | |
| public | No | Whether the playlist should be public |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"description": {
"description": "The description of the playlist",
"type": "string"
},
"name": {
"description": "The name of the playlist",
"type": "string"
},
"public": {
"description": "Whether the playlist should be public",
"type": "boolean"
}
},
"required": [
"name"
],
"type": "object"
}
Implementation Reference
- src/play.ts:182-203 (handler)The handler function that implements the createPlaylist tool logic. It retrieves the current user profile, creates a new playlist using the Spotify API with the provided name, description, and public setting, and returns a success message with the new 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:169-181 (schema)The schema definition for the createPlaylist tool, specifying input parameters: name (required string), description (optional string), and public (optional 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/play.ts:362-371 (registration)The createPlaylist tool is included in the exported playTools array, which collects playback-related tools for registration.export const playTools = [ playMusic, pausePlayback, skipToNext, skipToPrevious, createPlaylist, addTracksToPlaylist, resumePlayback, addToQueue, ];
- src/index.ts:12-14 (registration)The playTools array (including createPlaylist) is spread and each tool is registered with the MCP server using server.tool().[...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });