Skip to main content
Glama
leehave

Claude Music MCP

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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('add to') which implies a write/mutation operation, but doesn't disclose any behavioral traits such as required permissions, whether duplicates are allowed, error handling, or rate limits. This leaves significant gaps for an agent to understand how to use it safely and effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese ('将歌曲添加到播放列表'), which translates directly to 'Add songs to a playlist'. It's front-loaded with the core action and resource, with zero wasted words or redundant information, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a write operation with no annotations and no output schema, the description is incomplete. It doesn't address what happens on success (e.g., confirmation, updated playlist) or failure (e.g., errors for invalid IDs), nor does it provide context on permissions or side effects. For a mutation tool, this leaves critical gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting both parameters ('playlistId' and 'songId') as required IDs. The description adds no additional meaning beyond this, as it doesn't explain parameter formats, sources, or relationships. Baseline score of 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('add to') and resource ('playlist'), specifying it's for adding songs. It distinguishes from siblings like 'create_playlist' or 'list_playlists' by focusing on modification rather than creation or retrieval. However, it doesn't explicitly mention what type of resource 'songs' are (e.g., tracks, audio files), leaving some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing playlist and song), exclusions, or comparisons to siblings like 'create_playlist' for new playlists or 'search_music' to find songs first. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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