Skip to main content
Glama

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
NameRequiredDescriptionDefault
audio_urlYesURL of the audio file to convert
output_formatYesDesired output format
webhook_urlNoURL for callback upon completion

Implementation Reference

  • 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.`,
          },
        ],
      };
    }
  • 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);

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/pasie15/mcp-server-musicgpt'

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