get_playlist
Retrieve detailed information about a specific music playlist using its unique ID. This tool enables users to access playlist contents, metadata, and structure for music management within the Claude Music MCP server.
Instructions
获取播放列表信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlistId | Yes | 播放列表ID |
Implementation Reference
- src/index.ts:262-284 (handler)The primary handler function for the 'get_playlist' tool that executes the core logic: fetches playlist data, retrieves associated songs, and formats a detailed response.private async handleGetPlaylist(args: any) { const { playlistId } = args; const playlist = await this.playlistManager.getPlaylist(playlistId); if (!playlist) { throw new Error(`未找到ID为 ${playlistId} 的播放列表`); } const songs = await Promise.all( playlist.songIds.map(id => this.musicDb.getSongById(id)) ); return { content: [ { type: 'text', text: `🎵 播放列表: ${playlist.name}\n\n描述: ${playlist.description || '无'}\n歌曲数量: ${playlist.songIds.length}\n创建时间: ${playlist.createdAt}\n\n歌曲列表:\n${songs.map((song, index) => `${index + 1}. ${song?.title} - ${song?.artist}` ).join('\n')}`, }, ], }; }
- src/index.ts:115-128 (registration)Registration of the 'get_playlist' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.{ name: 'get_playlist', description: '获取播放列表信息', inputSchema: { type: 'object', properties: { playlistId: { type: 'string', description: '播放列表ID', }, }, required: ['playlistId'], }, },
- src/playlist-manager.ts:1-8 (schema)TypeScript interface defining the Playlist data structure used throughout the get_playlist implementation.export interface Playlist { id: string; name: string; description?: string; songIds: string[]; createdAt: string; updatedAt: string; }
- src/playlist-manager.ts:31-33 (helper)Supporting method in PlaylistManager class that retrieves a specific playlist by ID, called by the main handler.async getPlaylist(id: string): Promise<Playlist | undefined> { return this.playlists.get(id); }
- src/index.ts:177-178 (registration)Tool dispatching logic in the CallToolRequestSchema switch statement that routes 'get_playlist' calls to the handler.case 'get_playlist': return await this.handleGetPlaylist(args);