Skip to content

refactor(server): parameter 'format' shadows Python builtin + manual CLI arg parser should use argparse #67

@alfonsodg

Description

@alfonsodg

Problem 1: format shadows builtin

text_to_audio() and music_generation() use format as a parameter name, which shadows the Python builtin format() function.

Exact location

  • minimax_mcp/server.py, functions text_to_audio() and music_generation()
def text_to_audio(
    ...
    format: str = DEFAULT_FORMAT,  # shadows builtin
):

Proposed fix

Rename to audio_format or output_format:

def text_to_audio(
    ...
    audio_format: str = DEFAULT_FORMAT,
):

Problem 2: Manual CLI argument parser

The CLI argument parsing at module level uses a manual loop instead of argparse:

cli_args = {}
args = sys.argv[1:]
for i in range(len(args)):
    if args[i].startswith("--"):
        key_value = args[i][2:].split("=", 1)
        ...

Issues with manual parser

  • No --help support
  • No validation of argument names
  • No error messages for malformed arguments
  • Inconsistent with __main__.py which already uses argparse

Proposed fix

import argparse

def _parse_cli_args():
    parser = argparse.ArgumentParser(description="MiniMax MCP Server")
    parser.add_argument("--api-key", help="MiniMax API key")
    parser.add_argument("--base-path", help="Output base path")
    parser.add_argument("--api-host", help="API host URL")
    parser.add_argument("--resource-mode", choices=["url", "local"], help="Resource mode")
    parser.add_argument("--log-level", default="WARNING", help="Log level")
    args, _ = parser.parse_known_args()
    return vars(args)

Acceptance criteria

  • No parameter names that shadow Python builtins
  • CLI arguments parsed with argparse with --help support
  • Consistent argument handling between server.py and __main__.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions