Skip to content

feat(server): validate numeric and enum tool params locally before API calls (#66)#85

Open
TumCucTom wants to merge 1 commit into
MiniMax-AI:mainfrom
TumCucTom:fix/mcp-66-input-validation
Open

feat(server): validate numeric and enum tool params locally before API calls (#66)#85
TumCucTom wants to merge 1 commit into
MiniMax-AI:mainfrom
TumCucTom:fix/mcp-66-input-validation

Conversation

@TumCucTom
Copy link
Copy Markdown

Summary

  • Add validation enums and ranges to minimax_mcp/const.py.
  • New module minimax_mcp/validators.py with _validate_range() and _validate_enum() helpers that raise MinimaxValidationError.
  • Wire validation into text_to_audio, text_to_image, and music_generation at the top of each function body.
  • New test file tests/test_validators.py covering all helpers and the documented tool params.

Why

Issue #66: invalid numeric/enum values were forwarded to the API, producing cryptic errors and wasting quota. Local validation surfaces clear messages up front and prevents impossible requests.

Test plan

  • tests/test_validators.py covers range and enum helpers, boundary values, and end-to-end tool function calls
  • pytest tests/ green

Fixes #66.

🤖 Generated with Claude Code

…I calls

Tool functions (text_to_audio, text_to_image, music_generation) accept
parameters with documented valid ranges and enums but performed no local
validation. Invalid values were forwarded to the API, producing cryptic
errors and wasting API quota on requests that could never succeed.

Add per-parameter validation:
- Module-level enums for sample_rate / bitrate / emotion / format /
  aspect_ratio, and ranges for speed / vol / pitch / channel / n.
- _validate_range() and _validate_enum() helpers in
  minimax_mcp/validators.py that raise MinimaxValidationError (already
  defined in exceptions.py) with a clear message.
- Validation calls at the top of each affected tool function.

Fixes MiniMax-AI#66.

Co-authored-by: Zippy AI <tomkinsbale@icloud.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

fix(server): no input validation for numeric parameters — speed, vol, pitch, n, sample_rate, bitrate

1 participant