Skip to main content
Glama

generate_music

Create custom AI-generated music from text prompts, producing songs with or without lyrics, instrumental tracks, or vocal-only versions based on specified styles.

Instructions

Generate custom music from a text prompt using AI. Can create songs with or without lyrics, instrumental tracks, or vocal-only versions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesNatural language prompt for music generation (keep under 280 characters for best results)
music_styleNoStyle of music to generate (e.g., Rock, Pop, Jazz, Hip-Hop)
lyricsNoCustom lyrics for the generated music
make_instrumentalNoWhether to make the music instrumental (no vocals)
vocal_onlyNoWhether to generate only vocals of output audio
voice_idNoVoice model ID to use for vocals (use get_all_voices to find IDs)
webhook_urlNoURL for callback upon completion

Implementation Reference

  • The core handler function that implements the generate_music tool logic by making an API call to the MusicGPT /MusicAI endpoint with the provided arguments and returning a status response.
    private async handleGenerateMusic(args: any) {
      if (!args.prompt) {
        throw new McpError(ErrorCode.InvalidParams, "prompt is required");
      }
    
      const response = await this.axiosInstance.post("/MusicAI", {
        prompt: args.prompt,
        music_style: args.music_style,
        lyrics: args.lyrics,
        make_instrumental: args.make_instrumental || false,
        vocal_only: args.vocal_only || false,
        voice_id: args.voice_id,
        webhook_url: args.webhook_url,
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Music generation started!\n\n${JSON.stringify(response.data, null, 2)}\n\nUse get_conversion_by_id with the task_id or conversion_id to check the status.`,
          },
        ],
      };
    }
  • The input schema and description for the generate_music tool, defining parameters like prompt, music_style, lyrics, etc., used for validation in MCP.
      name: "generate_music",
      description: "Generate custom music from a text prompt using AI. Can create songs with or without lyrics, instrumental tracks, or vocal-only versions.",
      inputSchema: {
        type: "object" as const,
        properties: {
          prompt: {
            type: "string",
            description: "Natural language prompt for music generation (keep under 280 characters for best results)",
          },
          music_style: {
            type: "string",
            description: "Style of music to generate (e.g., Rock, Pop, Jazz, Hip-Hop)",
          },
          lyrics: {
            type: "string",
            description: "Custom lyrics for the generated music",
          },
          make_instrumental: {
            type: "boolean",
            description: "Whether to make the music instrumental (no vocals)",
            default: false,
          },
          vocal_only: {
            type: "boolean",
            description: "Whether to generate only vocals of output audio",
            default: false,
          },
          voice_id: {
            type: "string",
            description: "Voice model ID to use for vocals (use get_all_voices to find IDs)",
          },
          webhook_url: {
            type: "string",
            description: "URL for callback upon completion",
          },
        },
        required: ["prompt"],
      },
    },
  • src/index.ts:669-670 (registration)
    The switch case in the main tool execution handler that registers and dispatches 'generate_music' calls to the specific handleGenerateMusic function.
    case "generate_music":
      return await this.handleGenerateMusic(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