analyze_music
Extract genre, mood, tempo, key, and instruments from audio files to classify music and enhance discovery. Accepts MP3, WAV, FLAC, OGG, or M4A URLs.
Instructions
Analyze an audio file to extract genre, mood, tempo, key, and detected instruments. Accepts a public URL to an audio file (MP3, WAV, FLAC, OGG, M4A). Returns structured tags useful for music classification and discovery.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audio_url | Yes | Public URL to the audio file to analyze |
Implementation Reference
- src/tools/analyze-music.ts:42-65 (handler)The handler function that validates the audio_url input, calls the IRCAM Music Tagger API via httpPost, handles errors, and returns the transformed MusicAnalysisResult.export async function handleAnalyzeMusic( args: Record<string, unknown> ): Promise<MusicAnalysisResult> { const audioUrl = args.audio_url as string; // Validate input const validation = validateAudioUrl(audioUrl); if (!validation.valid) { throw validation.error; } // Call IRCAM Music Tagger API const url = buildApiUrl(IRCAM_API_CONFIG.ENDPOINTS.MUSIC_TAGGER); const response = await httpPost<IrcamMusicTaggerResponse>(url, { url: audioUrl, }); if (!response.ok || !response.data) { throw response.error || formatError('UNKNOWN_ERROR', 'Failed to analyze music'); } // Transform and return result return transformMusicTaggerResponse(response.data); }
- src/tools/analyze-music.ts:21-37 (schema)The tool definition including the inputSchema that requires a public audio_url string.export const analyzeMusicTool: Tool = { name: 'analyze_music', description: 'Analyze an audio file to extract genre, mood, tempo, key, and detected instruments. ' + 'Accepts a public URL to an audio file (MP3, WAV, FLAC, OGG, M4A). ' + 'Returns structured tags useful for music classification and discovery.', inputSchema: { type: 'object', properties: { audio_url: { type: 'string', description: 'Public URL to the audio file to analyze', }, }, required: ['audio_url'], }, };
- src/index.ts:48-54 (registration)Maps the 'analyze_music' tool name to its handler function handleAnalyzeMusic for execution in the MCP server.const TOOL_HANDLERS: Record<string, (args: Record<string, unknown>) => Promise<unknown>> = { analyze_music: handleAnalyzeMusic, separate_stems: handleSeparateStems, detect_ai_music: handleDetectAiMusic, analyze_loudness: handleAnalyzeLoudness, check_job_status: handleCheckJobStatus, };
- src/index.ts:37-43 (registration)Registers the analyzeMusicTool in the list of available tools returned by listTools.const TOOLS = [ analyzeMusicTool, separateStemsTool, detectAiMusicTool, analyzeLoudnessTool, checkJobStatusTool, ];
- src/types/mcp-tools.ts:84-95 (schema)TypeScript interface defining the output structure of the analyze_music tool.export interface MusicAnalysisResult { /** Genres détectés (ex: ["electronic", "house"]) */ genre: string[]; /** Ambiances/moods (ex: ["energetic", "uplifting"]) */ mood: string[]; /** Tempo en BPM */ tempo: number; /** Tonalité (ex: "C major", "A minor") */ key: string; /** Instruments détectés */ instruments: string[]; }