Skip to main content
Glama
falahgs

MCP MiniMax Music Server

by falahgs

generate_audio

Generate audio content from text prompts using AI models, supporting lyric formatting and reference audio for music creation.

Instructions

Generate audio using AIML API. The process has two steps: 1) Submit generation request 2) Get the generated audio. If generation_id is not provided, it will start a new generation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoThe model to use for generation (stable-audio or minimax-music)minimax-music
reference_audio_urlNoURL of the reference audio (required for minimax-music)https://tand-dev.github.io/audio-hosting/spinning-head-271171.mp3
promptYesThe text prompt for audio generation. For minimax-music, wrap lyrics in ##...##
api_keyNoYour AIML API Key (optional if set in environment variables)
generation_idNoOptional: The generation ID from a previous request to check status

Implementation Reference

  • Tool handler for 'generate_audio' which submits the request or checks the status based on provided parameters.
    server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest) => {
      if (request.params.name === "generate_audio") {
        try {
          const args = request.params.arguments;
          if (!args || typeof args !== 'object' || !('prompt' in args)) {
            throw new McpError(ErrorCode.InvalidRequest, "Missing required parameter: prompt");
          }
    
          const apiKey = args.api_key ? String(args.api_key) : process.env.AIML_API_KEY;
          if (!apiKey) {
            throw new McpError(
              ErrorCode.InvalidRequest,
              "API key not found. Please provide it in claude_desktop_config.json or as a parameter"
            );
          }
    
          const params: AudioGenerationParams = {
            prompt: String(args.prompt),
            api_key: apiKey,
            model: args.model ? String(args.model) : "minimax-music",
            reference_audio_url: args.reference_audio_url ? String(args.reference_audio_url) : undefined,
            generation_id: args.generation_id ? String(args.generation_id) : undefined
          };
    
          if (params.generation_id) {
            const status = await checkGenerationStatus(params.generation_id, params.api_key);
            return { toolResult: status };
          }
    
          const url = "https://api.aimlapi.com/v2/generate/audio";
          
          if (params.model === "minimax-music" && !params.prompt.startsWith("##")) {
            params.prompt = `##${params.prompt}##`;
          }
    
          const payload: GenerationPayload = {
            model: params.model || "minimax-music",
            prompt: params.prompt
          };
    
          if (params.model === "minimax-music") {
            payload.reference_audio_url = params.reference_audio_url || 
              "https://tand-dev.github.io/audio-hosting/spinning-head-271171.mp3";
          }
    
          const response = await fetch(url, {
            method: 'POST',
            headers: {
              'Authorization': params.api_key.startsWith('Bearer ') ? params.api_key : `Bearer ${params.api_key}`,
              'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
          });
    
          if (!response.ok) {
            throw new McpError(
              ErrorCode.InvalidRequest,
              `Failed to generate audio: HTTP ${response.status}`
            );
          }
    
          const data = await response.json();
          if (!data || typeof data !== 'object' || !('status' in data) || !('id' in data)) {
            throw new McpError(ErrorCode.InvalidRequest, 'Invalid response format from server');
          }
    
          const result = data as GenerationResponse;
          return { 
            toolResult: {
              status: result.status,
              id: result.id,
              message: "Generation started! Use this generation_id to check status in subsequent calls.",
              next_step: "Call this tool again with the same API key and this generation_id to check status."
            }
          };
        } catch (error: unknown) {
          if (error instanceof McpError) {
            throw error;
          }
          throw new McpError(
            ErrorCode.InvalidRequest,
            `Failed to generate audio: ${error instanceof Error ? error.message : 'Unknown error'}`
          );
        }
      }
      throw new McpError(ErrorCode.InvalidRequest, "Tool not found");
    });
  • Tool registration and schema definition for 'generate_audio'.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [{
          name: "generate_audio",
          description: "Generate audio using AIML API. The process has two steps: 1) Submit generation request 2) Get the generated audio. If generation_id is not provided, it will start a new generation.",
          inputSchema: {
            type: "object",
            properties: {
              model: {
                type: "string",
                description: "The model to use for generation (stable-audio or minimax-music)",
                default: "minimax-music"
              },
              reference_audio_url: {
                type: "string",
                description: "URL of the reference audio (required for minimax-music)",
                default: "https://tand-dev.github.io/audio-hosting/spinning-head-271171.mp3"
              },
              prompt: {
                type: "string",
                description: "The text prompt for audio generation. For minimax-music, wrap lyrics in ##...##"
              },
              api_key: {
                type: "string",
                description: "Your AIML API Key (optional if set in environment variables)"
              },
              generation_id: {
                type: "string",
                description: "Optional: The generation ID from a previous request to check status"
              }
            },
            required: ["prompt"]
          }
        }]
      };
    });
  • Helper function to check the status of an existing audio generation request.
    async function checkGenerationStatus(generationId: string, apiKey: string): Promise<GenerationResponse> {
      const url = "https://api.aimlapi.com/v2/generate/audio";
      const response = await fetch(`${url}?generation_id=${generationId}`, {
        method: 'GET',
        headers: {
          'Authorization': apiKey.startsWith('Bearer ') ? apiKey : `Bearer ${apiKey}`,
          'Content-Type': 'application/json'
        }
      });
    
      if (!response.ok) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          `Failed to check generation status: HTTP ${response.status}`
        );
      }
    
      const data = await response.json();
      if (!data || typeof data !== 'object' || !('status' in data) || !('id' in data)) {
        throw new McpError(ErrorCode.InvalidRequest, 'Invalid response format from server');
      }
      
      return data as GenerationResponse;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the two-step process and conditional behavior based on generation_id, but fails to cover critical aspects like authentication needs (beyond the optional api_key hint), rate limits, error handling, or what the output entails (e.g., audio file format, size). This is inadequate for a tool with potential mutations and external API calls.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose and key process steps. Both sentences earn their place by clarifying the tool's workflow, though it could be slightly more streamlined by integrating the conditional behavior more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an audio generation tool with no annotations and no output schema, the description is incomplete. It lacks details on what the tool returns (e.g., audio URL, generation status), error conditions, or performance expectations, leaving significant gaps for the agent to operate effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema, only implying that generation_id relates to checking status of a previous request, which is already suggested in the schema's description. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate audio using AIML API' with a two-step process. It specifies the action (generate audio) and the resource (AIML API), but doesn't distinguish from siblings since there are none, making it clear but not fully optimized for differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by explaining the two-step process and stating that if generation_id is not provided, it starts a new generation. However, it lacks explicit when-to-use scenarios, prerequisites, or alternatives, leaving some ambiguity for the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/falahgs/mcp-minimax-music-server'

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