Skip to content

feat: deps cleanup, format→audio_format rename, argparse CLI, CI pipeline, tests#74

Open
alfonsodg wants to merge 4 commits intoMiniMax-AI:mainfrom
alfonsodg:feat/enhancements-65-67-71
Open

feat: deps cleanup, format→audio_format rename, argparse CLI, CI pipeline, tests#74
alfonsodg wants to merge 4 commits intoMiniMax-AI:mainfrom
alfonsodg:feat/enhancements-65-67-71

Conversation

@alfonsodg
Copy link
Copy Markdown

Summary

Enhancements to improve code quality, reduce install size, and add CI/testing infrastructure.

Changes

1. Remove unused dependencies (#65)

Removed 5 packages from pyproject.toml that are declared but never imported:

  • fastapi, uvicorn — server uses mcp.server.fastmcp.FastMCP, not FastAPI
  • httpx — code uses requests everywhere
  • sounddevice, soundfileplay() uses ffplay subprocess

2. Rename format parameter to audio_format (#67)

  • format shadows Python builtin format() in text_to_audio() and music_generation()
  • Renamed to audio_format — API payload key remains "format" (no breaking change to API)

3. Replace manual CLI arg parser with argparse (#67)

  • Manual sys.argv loop replaced with argparse.ArgumentParser + parse_known_args()
  • Adds --help support, argument validation, consistent with __main__.py

4. GitHub Actions CI (#71)

  • .github/workflows/ci.yml — runs ruff check, ruff format --check, pytest on Python 3.10 + 3.12

5. docs/STANDARDS.md (#71)

  • Documents coding standards: ruff, pytest, timeouts, context managers, conventional commits

6. New tests

  • tests/test_client.py — 6 tests for auth headers, API error codes (1004, generic), network errors, timeout
  • tests/test_validation.py — 10 tests for parameter range validation

All 22 tests pass. Coverage: 41%.

- Add --api-key, --base-path, --api-host, --resource-mode arguments
- CLI arguments take precedence over environment variables
- Improves compatibility with GitHub Copilot CLI
- Update README with both configuration options
… leak, validation, paths, version, indentation

- fix(client): add REQUEST_TIMEOUT=30s to all API requests (MiniMax-AI#64)
- fix(server): add DOWNLOAD_TIMEOUT=120s to all requests.get() calls (MiniMax-AI#64)
- fix(server): play_audio use context manager for file handle (MiniMax-AI#63)
- fix(server): play_audio add timeout+raise_for_status for URL mode (MiniMax-AI#63)
- fix(server): music_generation fix indentation (8sp→4sp) and misaligned paren (MiniMax-AI#69)
- fix(init): sync __version__ 0.0.17→0.0.18 to match pyproject.toml (MiniMax-AI#62)
- fix(server): add _validate_audio_params for speed/vol/pitch/sample_rate/bitrate/n (MiniMax-AI#66)
- refactor(server): remove redundant output_path.parent.mkdir (build_output_path already creates dir) (MiniMax-AI#61)
- refactor(server): use build_output_file return value directly (already includes full path) (MiniMax-AI#61)
- chore(gitignore): add AGENTS.md and copilot config exclusions

Ref MiniMax-AI#61 Ref MiniMax-AI#62 Ref MiniMax-AI#63 Ref MiniMax-AI#64 Ref MiniMax-AI#66 Ref MiniMax-AI#69
…leanup, format rename, argparse, CI, tests

- chore(deps): remove unused fastapi, uvicorn, httpx, sounddevice, soundfile (MiniMax-AI#65)
- refactor(server): rename param format→audio_format to avoid shadowing builtin (MiniMax-AI#67)
- refactor(server): replace manual CLI arg parser with argparse (MiniMax-AI#67)
- ci: add GitHub Actions workflow with ruff + pytest matrix 3.10/3.12 (MiniMax-AI#71)
- docs: add docs/STANDARDS.md with project coding standards (MiniMax-AI#71)
- test: add test_client.py (6 tests) and test_validation.py (10 tests)

Ref MiniMax-AI#65 Ref MiniMax-AI#67 Ref MiniMax-AI#71
Copilot AI review requested due to automatic review settings April 18, 2026 14:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the MiniMax MCP package by reducing runtime dependency bloat, clarifying API/tool parameters, adding input validation + HTTP timeouts, and introducing CI/testing + development standards documentation.

Changes:

  • Remove unused runtime dependencies from pyproject.toml.
  • Rename tool parameters from formataudio_format, add _validate_audio_params, and switch server CLI parsing to argparse.
  • Add GitHub Actions CI, coding standards docs, and new pytest coverage for client + validation behavior.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyproject.toml Drops unused dependencies; bumps project version; defines pytest options.
minimax_mcp/server.py Adds argparse-based CLI config precedence, parameter validation, formataudio_format rename, and download timeouts.
minimax_mcp/client.py Sets a default request timeout via REQUEST_TIMEOUT.
minimax_mcp/const.py Introduces timeout constants and valid-range/enum sets used for validation.
.github/workflows/ci.yml Adds CI pipeline running ruff + pytest on 3.10/3.12.
docs/STANDARDS.md Documents lint/format/test/timeout conventions.
tests/test_client.py Adds tests for auth header behavior, error mapping, network errors, and timeout presence.
tests/test_validation.py Adds tests for _validate_audio_params range/enum enforcement.
README.md Documents new CLI argument approach for configuration.
.gitignore Ignores AI agent/copilot instruction files.
minimax_mcp/__init__.py Version bump to 0.0.18.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minimax_mcp/server.py
format: str = DEFAULT_FORMAT,
audio_format: str = DEFAULT_FORMAT,
output_directory: str = None
) -> TextContent:
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

music_generation now takes audio_format, but the tool description/docstring above still documents the argument as format. Please update the user-facing docs to match the new parameter name (while keeping the JSON payload key as format if required by the API).

Suggested change
) -> TextContent:
) -> TextContent:
"""Create a music generation task using AI models.
Args:
prompt: Style and content guidance for the generated music.
lyrics: Lyrics to use for the song.
sample_rate: Output audio sample rate.
bitrate: Output audio bitrate.
audio_format: Output audio format for the generated file. This public
tool argument maps to the API payload field `audio_setting.format`.
output_directory: Optional directory where the generated file is saved.
Returns:
Text content with the path to the generated music file or generation status.
"""

Copilot uses AI. Check for mistakes.
Comment thread minimax_mcp/server.py
"""

import os
import sys
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

sys is imported but not used anywhere in this module; this will trigger ruff/pyflakes F401 in CI. Remove the unused import (or use it explicitly if needed).

Suggested change
import sys

Copilot uses AI. Check for mistakes.
Comment thread minimax_mcp/server.py
format: str = DEFAULT_FORMAT,
audio_format: str = DEFAULT_FORMAT,
language_boost: str = DEFAULT_LANGUAGE_BOOST,
):
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The tool signature now uses audio_format, but the tool description still documents the parameter as format. This is user-facing and can confuse callers; update the docstring/Args section to use audio_format (and keep noting that the API payload key remains format).

Suggested change
):
):
"""Generate audio from text.
Args:
text: The text to convert to audio.
output_directory: Optional directory where the generated audio file will be saved.
voice_id: The voice ID to use for speech synthesis.
model: The speech synthesis model to use.
speed: Playback speed for the generated speech.
vol: Volume level for the generated speech.
pitch: Pitch adjustment for the generated speech.
emotion: Emotion setting for the generated speech.
sample_rate: Output audio sample rate.
bitrate: Output audio bitrate.
channel: Number of output audio channels.
audio_format: Output audio format. This tool argument is named `audio_format`,
while the downstream Minimax API payload still uses the key `format`.
language_boost: Language boost setting for speech generation.
Returns:
Text content with the path to the output file and name of the voice used.
"""

Copilot uses AI. Check for mistakes.
Comment thread minimax_mcp/const.py
VALID_SAMPLE_RATES = {8000, 16000, 22050, 24000, 32000, 44100}
VALID_BITRATES = {32000, 64000, 128000, 256000}
VALID_EMOTIONS = {"happy", "sad", "angry", "fearful", "disgusted", "surprised", "neutral"}
VALID_AUDIO_FORMATS = {"pcm", "mp3", "flac"}
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

VALID_AUDIO_FORMATS is used to validate audio_format, but it currently excludes "wav" while music_generation's documented supported formats include WAV. This will cause previously-accepted audio_format="wav" inputs to start raising MinimaxRequestError. Either add "wav" to the allowed set (if the API supports it) or tighten the docstring/tool args to match the enforced set, ideally using separate allowed-format sets per endpoint if they differ.

Suggested change
VALID_AUDIO_FORMATS = {"pcm", "mp3", "flac"}
VALID_AUDIO_FORMATS = {"pcm", "mp3", "flac", "wav"}

Copilot uses AI. Check for mistakes.
Comment thread minimax_mcp/server.py
Comment on lines +295 to +296
with open(output_file_name, "wb") as f:
f.write(requests.get(response_data.get("demo_audio"), timeout=DOWNLOAD_TIMEOUT).content)
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

When downloading demo_audio, the response is written to disk without checking the HTTP status. If the URL returns a 4xx/5xx (or HTML error body), the code will silently save invalid data. Fetch the URL into a response object and call raise_for_status() before writing, consistent with the other download paths in this file.

Suggested change
with open(output_file_name, "wb") as f:
f.write(requests.get(response_data.get("demo_audio"), timeout=DOWNLOAD_TIMEOUT).content)
demo_audio_response = requests.get(
response_data.get("demo_audio"),
timeout=DOWNLOAD_TIMEOUT
)
demo_audio_response.raise_for_status()
with open(output_file_name, "wb") as f:
f.write(demo_audio_response.content)

Copilot uses AI. Check for mistakes.
Comment thread tests/test_validation.py
@@ -0,0 +1,83 @@
import pytest
import os
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

os is imported but never used in this test module; this will fail ruff check (F401) in CI. Remove the unused import.

Suggested change
import os

Copilot uses AI. Check for mistakes.
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.

2 participants