feat: deps cleanup, format→audio_format rename, argparse CLI, CI pipeline, tests#74
feat: deps cleanup, format→audio_format rename, argparse CLI, CI pipeline, tests#74alfonsodg wants to merge 4 commits intoMiniMax-AI:mainfrom
Conversation
- 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
There was a problem hiding this comment.
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
format→audio_format, add_validate_audio_params, and switch server CLI parsing toargparse. - 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, format→audio_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.
| format: str = DEFAULT_FORMAT, | ||
| audio_format: str = DEFAULT_FORMAT, | ||
| output_directory: str = None | ||
| ) -> TextContent: |
There was a problem hiding this comment.
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).
| ) -> 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. | |
| """ |
| """ | ||
|
|
||
| import os | ||
| import sys |
There was a problem hiding this comment.
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).
| import sys |
| format: str = DEFAULT_FORMAT, | ||
| audio_format: str = DEFAULT_FORMAT, | ||
| language_boost: str = DEFAULT_LANGUAGE_BOOST, | ||
| ): |
There was a problem hiding this comment.
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).
| ): | |
| ): | |
| """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. | |
| """ |
| 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"} |
There was a problem hiding this comment.
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.
| VALID_AUDIO_FORMATS = {"pcm", "mp3", "flac"} | |
| VALID_AUDIO_FORMATS = {"pcm", "mp3", "flac", "wav"} |
| with open(output_file_name, "wb") as f: | ||
| f.write(requests.get(response_data.get("demo_audio"), timeout=DOWNLOAD_TIMEOUT).content) |
There was a problem hiding this comment.
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.
| 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) |
| @@ -0,0 +1,83 @@ | |||
| import pytest | |||
| import os | |||
There was a problem hiding this comment.
os is imported but never used in this test module; this will fail ruff check (F401) in CI. Remove the unused import.
| import os |
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.tomlthat are declared but never imported:fastapi,uvicorn— server usesmcp.server.fastmcp.FastMCP, not FastAPIhttpx— code usesrequestseverywheresounddevice,soundfile—play()usesffplaysubprocess2. Rename
formatparameter toaudio_format(#67)formatshadows Python builtinformat()intext_to_audio()andmusic_generation()audio_format— API payload key remains"format"(no breaking change to API)3. Replace manual CLI arg parser with
argparse(#67)sys.argvloop replaced withargparse.ArgumentParser+parse_known_args()--helpsupport, argument validation, consistent with__main__.py4. GitHub Actions CI (#71)
.github/workflows/ci.yml— runsruff check,ruff format --check,pyteston Python 3.10 + 3.125. docs/STANDARDS.md (#71)
6. New tests
tests/test_client.py— 6 tests for auth headers, API error codes (1004, generic), network errors, timeouttests/test_validation.py— 10 tests for parameter range validationAll 22 tests pass. Coverage: 41%.