convert_audio_format
Convert audio files between formats like MP3, WAV, FLAC, OGG, and M4A for compatibility with different devices and applications.
Instructions
Convert audio file to a different format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audio_url | Yes | URL of the audio file to convert | |
| output_format | Yes | Desired output format | |
| webhook_url | No | URL for callback upon completion |
Implementation Reference
- src/index.ts:1035-1054 (handler)The handler function that implements the core logic for the 'convert_audio_format' tool. It validates inputs, makes an API call to '/fileconvert' endpoint of MusicGPT API, and returns the task details with instructions for status checking.private async handleConvertAudioFormat(args: any) { if (!args.audio_url || !args.output_format) { throw new McpError(ErrorCode.InvalidParams, "audio_url and output_format are required"); } const response = await this.axiosInstance.post("/fileconvert", { audio_url: args.audio_url, output_format: args.output_format, webhook_url: args.webhook_url, }); return { content: [ { type: "text", text: `Audio format conversion started!\n\n${JSON.stringify(response.data, null, 2)}\n\nUse get_conversion_by_id with the task_id to check the status.`, }, ], }; }
- src/index.ts:334-356 (schema)The tool definition in the TOOLS array, including name, description, and detailed inputSchema with properties and requirements for the 'convert_audio_format' tool.{ name: "convert_audio_format", description: "Convert audio file to a different format", inputSchema: { type: "object" as const, properties: { audio_url: { type: "string", description: "URL of the audio file to convert", }, output_format: { type: "string", description: "Desired output format", enum: ["mp3", "wav", "flac", "ogg", "m4a"], }, webhook_url: { type: "string", description: "URL for callback upon completion", }, }, required: ["audio_url", "output_format"], }, },
- src/index.ts:695-696 (registration)The switch case in the CallToolRequestSchema handler that registers and routes calls to the 'convert_audio_format' tool to its handler method.case "convert_audio_format": return await this.handleConvertAudioFormat(args);