Skip to main content
Glama
leehave
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); }

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