From f69ae92f11f527522bb242391f5a04a45b00d6f1 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 19 Mar 2026 21:43:40 -0700 Subject: [PATCH] feat: add lyrics_generation tool for AI-powered song lyric creation Exposes the MiniMax lyrics generation API as an MCP tool, enabling a natural two-step workflow: generate lyrics first, then pass them to music_generation. Supports both full generation (type=1) and edit/refine mode (type=2). Co-Authored-By: Claude Opus 4.6 --- README-CN.md | 1 + README.md | 1 + minimax_mcp/const.py | 1 + minimax_mcp/server.py | 54 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/README-CN.md b/README-CN.md index a7f5f35..1df923c 100644 --- a/README-CN.md +++ b/README-CN.md @@ -103,6 +103,7 @@ |`voice_clone`|根据指定音频文件克隆音色| |`generate_video`|根据指定 prompt 生成视频| |`text_to_image`|根据指定 prompt 生成图片| +|`lyrics_generation`|根据描述提示词生成歌词| |`music_generation`|根据指定 prompt 和歌词生成音乐| |`voice_design`|根据指定 prompt 生成音色和试听文本| diff --git a/README.md b/README.md index 7d1a32c..d7374ee 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ We support two transport types: stdio and sse. |`generate_video`|Generate a video from a prompt| |`text_to_image`|Generate a image from a prompt| |`query_video_generation`|Query the result of video generation task| +|`lyrics_generation`|Generate song lyrics from a description prompt| |`music_generation`|Generate a music track from a prompt and lyrics| |`voice_design`|Generate a voice from a prompt using preview text| diff --git a/minimax_mcp/const.py b/minimax_mcp/const.py index d1c3964..49103b8 100644 --- a/minimax_mcp/const.py +++ b/minimax_mcp/const.py @@ -2,6 +2,7 @@ DEFAULT_VOICE_ID = "female-shaonv" DEFAULT_SPEECH_MODEL = "speech-2.6-hd" DEFAULT_MUSIC_MODEL = "music-2.0" +DEFAULT_LYRICS_MODEL = "lyrics-01" DEFAULT_SPEED = 1.0 DEFAULT_VOLUME = 1.0 DEFAULT_PITCH = 0 diff --git a/minimax_mcp/server.py b/minimax_mcp/server.py index c767441..626aa1a 100644 --- a/minimax_mcp/server.py +++ b/minimax_mcp/server.py @@ -571,6 +571,60 @@ def text_to_image( text=f"Failed to save images: {str(e)}" ) +@mcp.tool( + description="""Generate song lyrics from a description prompt using AI. + + COST WARNING: This tool makes an API call to Minimax which may incur costs. + Only use when explicitly requested by the user. + + Args: + prompt (str): Description of the song style, mood, theme, etc. + Example: "A melancholic ballad about rainy nights in the city" + type (int, optional): Generation type. 1 = generate full lyrics, + 2 = edit/refine existing lyrics. Defaults to 1. + lyrics (str, optional): Existing lyrics to refine (required when type=2). + + Returns: + Text content with the generated lyrics including structure tags. + """ +) +def lyrics_generation( + prompt: str, + type: int = 1, + lyrics: str = None, +) -> TextContent: + try: + if not prompt: + raise MinimaxRequestError("Prompt is required.") + + payload = { + "model": DEFAULT_LYRICS_MODEL, + "prompt": prompt, + "type": type, + } + if lyrics is not None: + payload["lyrics"] = lyrics + + response_data = api_client.post("/v1/lyrics_generation", json=payload) + + data = response_data.get("data", {}) + generated_lyrics = data.get("lyrics", "") + + if not generated_lyrics: + raise MinimaxRequestError("No lyrics generated") + + return TextContent( + type="text", + text=f"Success. Generated lyrics:\n{generated_lyrics}", + ) + + except MinimaxAPIError as e: + return TextContent( + type="text", + text=f"Failed to generate lyrics: {str(e)}" + ) + + @mcp.tool( description="""Create a music generation task using AI models. Generate music from prompt and lyrics.