generate_music
Create custom music from text prompts using AI. Generate songs with or without lyrics, instrumental tracks, or vocal-only versions based on specified styles and parameters.
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
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Natural language prompt for music generation (keep under 280 characters for best results) | |
| music_style | No | Style of music to generate (e.g., Rock, Pop, Jazz, Hip-Hop) | |
| lyrics | No | Custom lyrics for the generated music | |
| make_instrumental | No | Whether to make the music instrumental (no vocals) | |
| vocal_only | No | Whether to generate only vocals of output audio | |
| voice_id | No | Voice model ID to use for vocals (use get_all_voices to find IDs) | |
| webhook_url | No | URL for callback upon completion |
Implementation Reference
- src/index.ts:829-852 (handler)The handler function that executes the generate_music tool. It validates the prompt, makes a POST request to the MusicGPT API /MusicAI endpoint with the provided arguments, and returns a response message with task details.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.`, }, ], }; }
- src/index.ts:124-159 (schema)Input schema defining the parameters for the generate_music tool, including prompt (required), music_style, lyrics, make_instrumental, vocal_only, voice_id, and webhook_url.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:121-160 (registration)Tool registration in the TOOLS array, which is returned by the listTools handler. Includes name, description, and inputSchema.{ 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)Dispatch registration in the callToolRequest switch statement that routes execution to the handleGenerateMusic method.case "generate_music": return await this.handleGenerateMusic(args);