Skip to content

refactor: split monolithic server.py (800+ lines) into separate tool modules #68

@alfonsodg

Description

@alfonsodg

Problem

minimax_mcp/server.py is a single 800+ line file containing all tool definitions, configuration, and the MCP server setup. This makes it hard to navigate, test, and maintain.

Current structure

minimax_mcp/
├── __init__.py      # 2 lines
├── __main__.py      # config generator
├── client.py        # API client (good, already separated)
├── const.py         # constants (good, already separated)
├── exceptions.py    # exceptions (good, already separated)
├── server.py        # 800+ lines — ALL tools + config + server setup
└── utils.py         # utilities (good, already separated)

Proposed structure

minimax_mcp/
├── __init__.py
├── __main__.py
├── client.py
├── const.py
├── exceptions.py
├── server.py        # ~50 lines — MCP setup, config, imports tools
├── utils.py
└── tools/
    ├── __init__.py  # exports all tool functions
    ├── audio.py     # text_to_audio, play_audio, list_voices
    ├── video.py     # generate_video, query_video_generation
    ├── image.py     # text_to_image
    ├── music.py     # music_generation
    └── voice.py     # voice_clone, voice_design

Benefits

  • Each tool module is independently testable
  • Easier to add new tools without touching a massive file
  • Clear separation of concerns
  • Reduces merge conflicts when multiple contributors work on different tools

Implementation notes

  • Each tool module receives mcp, api_client, base_path, resource_mode as module-level or injected dependencies
  • server.py imports and registers all tools
  • No behavior change — purely structural refactor

Acceptance criteria

  • server.py reduced to <100 lines
  • Each tool in its own module
  • All existing tests pass
  • uvx minimax-mcp works identically

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions