Skip to main content
Glama
leehave

Claude Music MCP

by leehave

get_recommendations

Get personalized music recommendations based on genre preferences and current mood to discover new songs and artists.

Instructions

根据用户喜好获取音乐推荐

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
genreNo音乐风格
moodNo心情/氛围
limitNo推荐数量

Implementation Reference

  • Primary MCP tool handler for 'get_recommendations'. Parses arguments, fetches recommendations from MusicDatabase, formats and returns the response as text content.
    private async handleGetRecommendations(args: any) {
      const { genre, mood, limit = 10 } = args;
      const recommendations = await this.musicDb.getRecommendations(genre, mood, limit);
      
      return {
        content: [
          {
            type: 'text',
            text: `🎯 音乐推荐${genre ? ` (${genre})` : ''}${mood ? ` - ${mood}心情` : ''}:\n\n${recommendations.map(song => 
              `🎵 ${song.title}\n👤 ${song.artist}\n💿 ${song.album}\n⭐ ${song.rating}/5\n🆔 ${song.id}\n`
            ).join('\n')}`,
          },
        ],
      };
    }
  • src/index.ts:137-158 (registration)
    Tool registration in the ListToolsRequestHandler response. Defines the tool name, description, and input schema for validation.
    {
      name: 'get_recommendations',
      description: '根据用户喜好获取音乐推荐',
      inputSchema: {
        type: 'object',
        properties: {
          genre: {
            type: 'string',
            description: '音乐风格',
          },
          mood: {
            type: 'string',
            description: '心情/氛围',
          },
          limit: {
            type: 'number',
            description: '推荐数量',
            default: 10,
          },
        },
      },
    },
  • src/index.ts:181-182 (registration)
    Switch case registration in CallToolRequestHandler that routes calls to the handler function.
    case 'get_recommendations':
      return await this.handleGetRecommendations(args);
  • Supporting method in MusicDatabase class implementing the recommendation logic: filters by genre/mood, sorts by score, limits results.
    async getRecommendations(genre?: string, mood?: string, limit: number = 10): Promise<Song[]> {
      let filtered = [...this.songs];
    
      if (genre) {
        filtered = filtered.filter(song => 
          song.genre.toLowerCase().includes(genre.toLowerCase())
        );
      }
    
      // 根据心情推荐(简单的逻辑示例)
      if (mood) {
        const moodLower = mood.toLowerCase();
        if (moodLower.includes('快乐') || moodLower.includes('开心')) {
          filtered = filtered.filter(song => song.genre === 'Pop');
        } else if (moodLower.includes('安静') || moodLower.includes('放松')) {
          filtered = filtered.filter(song => song.rating >= 4);
        }
      }
    
      // 按评分和播放次数排序
      filtered.sort((a, b) => (b.rating * b.playCount) - (a.rating * a.playCount));
    
      return filtered.slice(0, limit);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does ('获取音乐推荐') without revealing any behavioral traits such as whether it's a read-only operation, if it requires authentication, rate limits, what the output format looks like (e.g., list of songs with details), or how recommendations are generated (e.g., based on history or explicit inputs). For a tool with no annotations, this is a significant gap in transparency.

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: '根据用户喜好获取音乐推荐'. It's front-loaded with the core purpose, has zero waste, and is appropriately sized for a straightforward tool. Every word earns its place by specifying the action, resource, and basis for the operation.

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 tool's moderate complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks information on behavioral aspects (e.g., read-only vs. mutation, output format), usage guidelines, and how parameters affect results. Without annotations or an output schema, the description should do more to compensate, such as hinting at return values or operational constraints, but it doesn't, leaving gaps for the agent.

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?

Schema description coverage is 100%, meaning all parameters ('genre', 'mood', 'limit') are documented in the schema with descriptions ('音乐风格', '心情/氛围', '推荐数量'). The description adds no additional meaning beyond what the schema provides—it doesn't explain how these parameters interact (e.g., if 'genre' and 'mood' are combined or prioritized) or provide examples. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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 '根据用户喜好获取音乐推荐' (Get music recommendations based on user preferences) clearly states the verb '获取' (get) and resource '音乐推荐' (music recommendations) with the scope '根据用户喜好' (based on user preferences). It distinguishes from siblings like 'search_music' (which likely searches rather than recommends) and 'get_song_info' (which retrieves song details rather than recommendations). However, it doesn't explicitly differentiate from all siblings, such as 'add_to_playlist' or 'create_playlist', which are related but distinct operations.

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 when to choose 'get_recommendations' over 'search_music' for finding music, or how it relates to playlist tools like 'add_to_playlist' or 'get_playlist'. There's no explicit context, exclusions, or prerequisites stated, leaving the agent to infer usage from the tool name and description alone.

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