Skip to main content
Glama
pixxelboy
by pixxelboy
detect-ai-music.ts1.84 kB
/** * detect_ai_music Tool * * Detects if audio was generated by AI or created by humans. */ import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { AIDetectionResult } from '../types/mcp-tools.js'; import { IRCAM_API_CONFIG, IrcamAIDetectorResponse, transformAIDetectorResponse, } from '../types/ircam-api.js'; import { httpPost, buildApiUrl } from '../utils/http.js'; import { validateAudioUrl } from '../utils/validation.js'; import { formatError } from '../utils/errors.js'; /** * Tool definition for MCP registration */ export const detectAiMusicTool: Tool = { name: 'detect_ai_music', description: 'Detect whether an audio file was generated by AI or created by humans. ' + 'Accepts a public URL to an audio file (MP3, WAV, FLAC, OGG, M4A). ' + 'Returns a confidence score (0-100) and classification (ai_generated, human_made, or uncertain).', inputSchema: { type: 'object', properties: { audio_url: { type: 'string', description: 'Public URL to the audio file to analyze', }, }, required: ['audio_url'], }, }; /** * Handle detect_ai_music tool call */ export async function handleDetectAiMusic( args: Record<string, unknown> ): Promise<AIDetectionResult> { const audioUrl = args.audio_url as string; // Validate input const validation = validateAudioUrl(audioUrl); if (!validation.valid) { throw validation.error; } // Call IRCAM AI Detector API const url = buildApiUrl(IRCAM_API_CONFIG.ENDPOINTS.AI_DETECTOR); const response = await httpPost<IrcamAIDetectorResponse>(url, { url: audioUrl, }); if (!response.ok || !response.data) { throw response.error || formatError('UNKNOWN_ERROR', 'Failed to detect AI music'); } // Transform and return result return transformAIDetectorResponse(response.data); }

Implementation Reference

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/pixxelboy/amplify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server