Skip to content

feat(asset-gen): add MiniMax music cover support - #1325

Open
octo-patch wants to merge 1 commit into
CoplayDev:betafrom
octo-patch:octo/20260812-music-cover-tool-recvrqnuAQtfbN
Open

feat(asset-gen): add MiniMax music cover support#1325
octo-patch wants to merge 1 commit into
CoplayDev:betafrom
octo-patch:octo/20260812-music-cover-tool-recvrqnuAQtfbN

Conversation

@octo-patch

@octo-patch octo-patch commented Aug 12, 2026

Copy link
Copy Markdown

Reason: The audio generation tool cannot create MiniMax covers from reference audio or parse cover responses.

Changes

  • Register MiniMax as an audio-cover provider with global and China regional endpoints and the current cover model choices.
  • Accept URL or base64 reference audio plus cover fields, response formats, audio encodings, and the regional watermark option through the MCP tool and CLI.
  • Parse synchronous completion status and URL or hex audio results into the existing Unity audio import pipeline.
  • Add routing, registry, request, response, validation, and key-redaction coverage, then regenerate the tool reference.

Checks

  • cd Server && ./.venv/bin/python -m pytest tests/test_asset_gen_audio.py -q
  • cd Server && ./.venv/bin/python ../tools/generate_docs_reference.py --check
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added MiniMax audio generation, including music-cover creation with URL or Base64 reference audio.
    • Added support for lyrics, instrumental mode, cover settings, output formats, and watermark options.
    • Added MiniMax models and provider visibility in the audio generation interface.
    • Added support for PCM audio results.
  • Documentation

    • Updated audio-generation guidance with provider-neutral workflows and cover-generation options.
  • Tests

    • Added coverage for MiniMax generation, validation, formats, regional endpoints, and response handling.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

MiniMax music-cover generation is added to the audio asset-generation flow. The change adds request fields, server forwarding, provider registration, model catalog entries, regional API handling, validation, polling, tests, and documentation.

Changes

MiniMax audio generation

Layer / File(s) Summary
Audio request and server bridge
MCPForUnity/Editor/Services/AssetGen/Providers/ProviderModels.cs, MCPForUnity/Editor/Tools/AssetGen/GenerateAudio.cs, Server/src/cli/commands/asset_gen.py, Server/src/services/tools/generate_audio.py, Server/tests/test_asset_gen_audio.py
Audio requests and server payloads now support lyrics, instrumental mode, reference audio, cover features, output formats, audio formats, and AIGC watermarking.
MiniMax submission and polling
MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs, MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs.meta, MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs.meta
The adapter validates cover requests, selects global or China endpoints, submits authenticated JSON requests, parses responses, redacts API keys, and returns URL or decoded audio results.
Provider registration and model selection
MCPForUnity/Editor/Services/AssetGen/Providers/AssetGenProviders.cs, MCPForUnity/Editor/Services/AssetGen/AssetGenModelCatalog.cs, MCPForUnity/Editor/Windows/Components/AssetGen/McpAssetGenSection.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenModelCatalogTests.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenProvidersTests.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/GenerateAudioTests.cs
MiniMax is registered as an audio provider with music, cover, URL, and base64 capabilities. The catalog includes music-cover and music-cover-free, and the editor lists MiniMax audio generation.
Audio tool documentation
website/docs/reference/tools/asset_gen/generate_audio.md, website/docs/reference/tools/asset_gen/index.md, website/docs/reference/tools/index.md
Documentation now uses provider-neutral audio-generation wording and describes cover inputs, formats, watermarking, and expiring result URLs.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: scriptwonder

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Server as generate_audio
  participant Unity as GenerateAudio
  participant Adapter as MiniMaxAudioAdapter
  participant API as MiniMax API
  Client->>Server: submit cover parameters
  Server->>Unity: forward audio payload
  Unity->>Adapter: create cover request
  Adapter->>API: POST authenticated JSON request
  API-->>Adapter: status and audio result
  Adapter-->>Unity: provider poll result
  Unity-->>Client: pending job or imported AudioClip
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes and checks, but it omits required template sections for change type, compatibility, testing checkboxes, documentation updates, and related issues. Use the repository template and complete the missing sections, including change type, Unity/package compatibility, testing status, documentation updates, related issues, and additional notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 2.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding MiniMax music cover support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs`:
- Around line 92-95: Update the shared download policy or transport used by
AssetGenJobManager.IsAllowedDownloadUrl to validate resolved hosts and reject
loopback, link-local, private-network, and other non-public addresses, while
also preventing redirects to disallowed destinations. Ensure the
MiniMaxAudioAdapter assignment to _downloadUrl cannot initiate a request until
the complete URL and redirect chain pass these checks.
- Around line 180-185: The audio pipeline must not expose raw pcm files as
importable results. In
MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs:180-185,
update NormalizeAudioFormat to reject pcm unless conversion to a supported
container is implemented; in
MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs:446, remove pcm from
AudioAllowedExtensions unless a custom importer exists; and in
TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs:127-146,
add end-to-end import coverage for every remaining accepted audio format.

In
`@TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/GenerateAudioTests.cs`:
- Line 23: Restore the previous MCPFORUNITY_MINIMAX_API_KEY value after each
test that clears it. Update the test class’s TearDown method to save the
original environment value before modification and restore it afterward,
preserving whether the variable was initially unset.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ed8f358-a147-448d-bff5-2f8196e17a5e

📥 Commits

Reviewing files that changed from the base of the PR and between c21bf49 and 0427453.

📒 Files selected for processing (19)
  • MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs
  • MCPForUnity/Editor/Services/AssetGen/AssetGenModelCatalog.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/AssetGenProviders.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs.meta
  • MCPForUnity/Editor/Services/AssetGen/Providers/ProviderModels.cs
  • MCPForUnity/Editor/Tools/AssetGen/GenerateAudio.cs
  • MCPForUnity/Editor/Windows/Components/AssetGen/McpAssetGenSection.cs
  • Server/src/cli/commands/asset_gen.py
  • Server/src/services/tools/generate_audio.py
  • Server/tests/test_asset_gen_audio.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenModelCatalogTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenProvidersTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/GenerateAudioTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs.meta
  • website/docs/reference/tools/asset_gen/generate_audio.md
  • website/docs/reference/tools/asset_gen/index.md
  • website/docs/reference/tools/index.md

Comment on lines +92 to +95
if (Uri.TryCreate(audio, UriKind.Absolute, out Uri audioUri)
&& (audioUri.Scheme == Uri.UriSchemeHttp || audioUri.Scheme == Uri.UriSchemeHttps))
{
_downloadUrl = audio;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Restrict provider-returned download URLs before use.

audio can contain any HTTP(S) URL. AssetGenJobManager.IsAllowedDownloadUrl checks only the scheme. It permits loopback, link-local, and private-network hosts.

A compromised or malicious provider response can make the Unity Editor request internal services. Enforce private-address and redirect validation in the shared transport or download policy before the request starts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs` around
lines 92 - 95, Update the shared download policy or transport used by
AssetGenJobManager.IsAllowedDownloadUrl to validate resolved hosts and reject
loopback, link-local, private-network, and other non-public addresses, while
also preventing redirects to disallowed destinations. Ensure the
MiniMaxAudioAdapter assignment to _downloadUrl cannot initiate a request until
the complete URL and redirect chain pass these checks.

Comment on lines +180 to +185
private static string NormalizeAudioFormat(string value)
{
string normalized = string.IsNullOrWhiteSpace(value) ? "mp3" : value.Trim().ToLowerInvariant();
if (normalized != "mp3" && normalized != "wav" && normalized != "pcm")
throw new ArgumentException("audio_format must be 'mp3', 'wav', or 'pcm'.");
return normalized;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

fd -a 'ProjectVersion.txt' .
fd -a -a 'AudioImportPipeline.cs' MCPForUnity TestProjects
rg -n -C 5 --glob '*.cs' 'pcm|AudioImportPipeline|AudioClip|AssetImporter' MCPForUnity TestProjects

Repository: CoplayDev/unity-mcp

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- MiniMaxAudioAdapter ---'
sed -n '1,240p' MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs

printf '%s\n' '--- AssetGenJobManager write/import flow ---'
sed -n '120,190p' MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs
sed -n '390,520p' MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs

printf '%s\n' '--- AudioImportPipeline ---'
cat -n MCPForUnity/Editor/Services/AssetGen/Import/AudioImportPipeline.cs

printf '%s\n' '--- Audio-related request/result models and tests ---'
rg -n -C 4 --glob '*.cs' 'class .*Audio|AudioFormat|OutputFormat|ResultExt|InlineData|OverrideExt|IsAllowedResultExtension|ImportOverrideForTests' MCPForUnity/Editor/Services/AssetGen TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen

Repository: CoplayDev/unity-mcp

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Runner poll/download/import state transitions ---'
sed -n '300,438p' MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs

printf '%s\n' '--- MiniMax adapter tests ---'
cat -n TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs

printf '%s\n' '--- Audio pipeline tests ---'
cat -n TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AudioImportPipelineTests.cs

printf '%s\n' '--- Extension allowlist tests and audio test helpers ---'
rg -n -C 8 --glob '*.cs' 'IsAllowedResultExtension|StartAudioGeneration|ImportOverrideForTests|OutputFormat|AudioFormat|MiniMax' TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen MCPForUnity/Editor/Services/AssetGen

Repository: CoplayDev/unity-mcp

Length of output: 50376


🌐 Web query:

Unity Manual audio file compatibility raw PCM .pcm supported import formats AudioImporter

💡 Result:

Unity does not support the import of raw PCM (.pcm) files directly [1][2][3]. While "PCM" is a widely supported compression format within Unity for runtime audio storage and playback, this refers to an uncompressed encoding method that Unity can apply to audio files during the import and transcoding process [4][5]. It is not a supported source file format for the AudioImporter [3][6]. The official supported source audio file formats that can be imported into Unity are: - Microsoft Wave (.wav) [1][2][3] - Audio Interchange File Format (.aiff,.aif) [1][2][3] - MPEG layer 3 (.mp3) [1][2][3] - Ogg Vorbis (.ogg) [1][2][3] - Free Lossless Audio Codec (.flac) [1][2][3] - Tracker modules (.mod,.it,.s3m,.xm) [7][2][3] When you import any of these supported files, the Unity AudioImporter allows you to specify the runtime compression format, where "PCM" can be selected to ensure the audio remains uncompressed for optimal CPU performance at the cost of larger file size [4][5]. Raw PCM data lacking a container format (like a.wav header) cannot be natively processed by the AudioImporter [3][6].

Citations:


Do not expose raw pcm as an importable audio result.

The job writes pcm bytes as .pcm under Assets/, but Unity does not import raw PCM source files. The bytes lack container metadata such as sample rate and channel count. The job can therefore fail or produce no usable AudioClip.

  • Reject pcm unless the pipeline converts it to a supported container.
  • Remove pcm from AudioAllowedExtensions unless a custom PCM importer exists.
  • Add end-to-end import coverage for each accepted audio format.
📍 Affects 3 files
  • MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs#L180-L185 (this comment)
  • MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs#L446-L446
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs#L127-L146
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs` around
lines 180 - 185, The audio pipeline must not expose raw pcm files as importable
results. In
MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs:180-185,
update NormalizeAudioFormat to reject pcm unless conversion to a supported
container is implemented; in
MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs:446, remove pcm from
AudioAllowedExtensions unless a custom importer exists; and in
TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs:127-146,
add end-to-end import coverage for every remaining accepted audio format.

{
AssetGenJobManager.ResetForTests();
Environment.SetEnvironmentVariable("MCPFORUNITY_FAL_API_KEY", null);
Environment.SetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY", null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore MCPFORUNITY_MINIMAX_API_KEY after each test.

Line 23 clears a process-wide environment variable. TearDown does not restore its prior value. Later tests can observe the changed environment and produce order-dependent results.

Proposed fix
 private string _dir;
 private EncryptedFileKeyStore _store;
+private string _originalMiniMaxApiKey;

 [SetUp]
 public void SetUp()
 {
     AssetGenJobManager.ResetForTests();
     Environment.SetEnvironmentVariable("MCPFORUNITY_FAL_API_KEY", null);
+    _originalMiniMaxApiKey = Environment.GetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY");
     Environment.SetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY", null);
@@
 public void TearDown()
 {
     AssetGenJobManager.ResetForTests();
     SecureKeyStore.ResetForTests();
+    Environment.SetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY", _originalMiniMaxApiKey);
     try { if (Directory.Exists(_dir)) Directory.Delete(_dir, true); } catch { }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Environment.SetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY", null);
private string _dir;
private EncryptedFileKeyStore _store;
private string _originalMiniMaxApiKey;
[SetUp]
public void SetUp()
{
AssetGenJobManager.ResetForTests();
Environment.SetEnvironmentVariable("MCPFORUNITY_FAL_API_KEY", null);
_originalMiniMaxApiKey = Environment.GetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY");
Environment.SetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY", null);
}
public void TearDown()
{
AssetGenJobManager.ResetForTests();
SecureKeyStore.ResetForTests();
Environment.SetEnvironmentVariable("MCPFORUNITY_MINIMAX_API_KEY", _originalMiniMaxApiKey);
try { if (Directory.Exists(_dir)) Directory.Delete(_dir, true); } catch { }
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/GenerateAudioTests.cs`
at line 23, Restore the previous MCPFORUNITY_MINIMAX_API_KEY value after each
test that clears it. Update the test class’s TearDown method to save the
original environment value before modification and restore it afterward,
preserving whether the variable was initially unset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant