Skip to main content
Glama
leehave
by leehave

add_to_playlist

Add a song to a specific playlist by providing the playlist ID and song ID. Simplifies music management within Claude Music MCP's ecosystem.

Instructions

将歌曲添加到播放列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlistIdYes播放列表ID
songIdYes歌曲ID

Implementation Reference

  • The main handler function for the 'add_to_playlist' tool. It extracts playlistId and songId from args, adds the song to the playlist via PlaylistManager, fetches song details, and returns a success message.
    private async handleAddToPlaylist(args: any) { const { playlistId, songId } = args; await this.playlistManager.addSongToPlaylist(playlistId, songId); const song = await this.musicDb.getSongById(songId); return { content: [ { type: 'text', text: `✅ 歌曲已添加到播放列表!\n\n歌曲: ${song?.title} - ${song?.artist}`, }, ], };
  • Input schema and metadata for the 'add_to_playlist' tool, defined in the ListToolsRequestSchema handler.
    { name: 'add_to_playlist', description: '将歌曲添加到播放列表', inputSchema: { type: 'object', properties: { playlistId: { type: 'string', description: '播放列表ID', }, songId: { type: 'string', description: '歌曲ID', }, }, required: ['playlistId', 'songId'], }, },
  • src/index.ts:175-176 (registration)
    Switch case in the CallToolRequestSchema handler that registers and routes 'add_to_playlist' calls to its handler function.
    case 'add_to_playlist': return await this.handleAddToPlaylist(args);
  • Supporting method in PlaylistManager that performs the actual addition of a song to a playlist, checking existence and avoiding duplicates.
    async addSongToPlaylist(playlistId: string, songId: string): Promise<void> { const playlist = this.playlists.get(playlistId); if (!playlist) { throw new Error(`播放列表 ${playlistId} 不存在`); } if (!playlist.songIds.includes(songId)) { playlist.songIds.push(songId); playlist.updatedAt = new Date().toISOString(); } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leehave/Claude-Music-Mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server