create-playlist
Generate a personalized Spotify playlist by specifying a name, optional description, and public or private visibility. Save and organize your favorite tracks with ease.
Instructions
Create a new playlist for the current user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Description of the playlist (optional) | |
| name | Yes | Name of the playlist | |
| public | No | Whether the playlist should be public (default: false) |
Implementation Reference
- index.ts:1253-1280 (handler)Handler for the 'create-playlist' tool: parses arguments using CreatePlaylistSchema, fetches user ID, creates a new playlist via Spotify API POST request to /users/{userId}/playlists, and returns the playlist details.if (name === "create-playlist") { const { name, description, public: isPublic } = CreatePlaylistSchema.parse(args); const userInfo = await spotifyApiRequest("/me"); const userId = userInfo.id; const playlist = await spotifyApiRequest( `/users/${userId}/playlists`, "POST", { name, description, public: isPublic, } ); return { content: [ { type: "text", text: `Playlist created successfully: Name: ${playlist.name} ID: ${playlist.id} URL: ${playlist.external_urls.spotify}`, }, ], }; }
- index.ts:182-186 (schema)Zod schema for validating input parameters of the create-playlist tool: requires 'name', optional 'description' and 'public' (defaults to false). Used in both registration inputSchema and handler parsing.const CreatePlaylistSchema = z.object({ name: z.string(), description: z.string().optional(), public: z.boolean().default(false), });
- index.ts:729-750 (registration)Tool registration in the ListTools response: defines name, description, and inputSchema matching the CreatePlaylistSchema.{ name: "create-playlist", description: "Create a new playlist for the current user", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the playlist", }, description: { type: "string", description: "Description of the playlist (optional)", }, public: { type: "boolean", description: "Whether the playlist should be public (default: false)", }, }, required: ["name"], }, },