create_playlist
Build personalized music playlists by specifying a name and optional description. Streamline music organization and enhance listening experiences with this playlist creation tool.
Instructions
创建新的播放列表
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | 播放列表描述 | |
| name | Yes | 播放列表名称 |
Implementation Reference
- src/index.ts:233-245 (handler)The MCP tool handler for 'create_playlist' that destructures input arguments, invokes PlaylistManager.createPlaylist, and returns a formatted success response containing the new playlist details.private async handleCreatePlaylist(args: any) { const { name, description } = args; const playlist = await this.playlistManager.createPlaylist(name, description); return { content: [ { type: 'text', text: `✅ 播放列表创建成功!\n\n名称: ${playlist.name}\n描述: ${playlist.description || '无'}\nID: ${playlist.id}\n创建时间: ${playlist.createdAt}`, }, ], }; }
- src/index.ts:82-94 (schema)Input schema definition for the 'create_playlist' tool, specifying required 'name' and optional 'description' parameters.inputSchema: { type: 'object', properties: { name: { type: 'string', description: '播放列表名称', }, description: { type: 'string', description: '播放列表描述', }, }, required: ['name'],
- src/index.ts:79-96 (registration)Tool registration in the ListToolsRequestSchema handler, defining the 'create_playlist' tool's name, description, and input schema.{ name: 'create_playlist', description: '创建新的播放列表', inputSchema: { type: 'object', properties: { name: { type: 'string', description: '播放列表名称', }, description: { type: 'string', description: '播放列表描述', }, }, required: ['name'], }, },
- src/playlist-manager.ts:14-29 (helper)Core logic for creating a new playlist in the PlaylistManager class, generating ID, initializing empty song list, and storing in memory.async createPlaylist(name: string, description?: string): Promise<Playlist> { const id = this.nextId.toString(); this.nextId++; const playlist: Playlist = { id, name, description, songIds: [], createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), }; this.playlists.set(id, playlist); return playlist; }
- src/playlist-manager.ts:1-8 (schema)TypeScript interface defining the structure of a Playlist object, used as return type for createPlaylist.export interface Playlist { id: string; name: string; description?: string; songIds: string[]; createdAt: string; updatedAt: string; }