Skip to main content
Glama
leehave
by leehave

add_to_playlist

Add songs to music playlists using song and playlist IDs. This tool helps organize your music collection by placing tracks into specific playlists for better listening management.

Instructions

将歌曲添加到播放列表

Input Schema

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

Implementation Reference

  • Main handler function for 'add_to_playlist' tool. Extracts playlistId and songId, delegates to playlistManager.addSongToPlaylist, fetches song info for response, and returns 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 definition for the 'add_to_playlist' tool, defining playlistId and songId as required string parameters.
    inputSchema: { type: 'object', properties: { playlistId: { type: 'string', description: '播放列表ID', }, songId: { type: 'string', description: '歌曲ID', }, }, required: ['playlistId', 'songId'], },
  • src/index.ts:175-176 (registration)
    Registration of the 'add_to_playlist' handler in the switch statement for tool dispatch.
    case 'add_to_playlist': return await this.handleAddToPlaylist(args);
  • Helper method implementing the core logic: retrieves playlist, checks existence, adds songId if not already present, updates timestamp.
    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(); } }
  • Type definition for Playlist used internally by the playlist manager.
    export interface Playlist { id: string; name: string; description?: string; songIds: string[]; createdAt: string; updatedAt: string; }

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