How minimax-ai/minimax-mcp-js works
Main Components
• MCP Client(s)
– Examples: Claude Desktop, Cursor, any MCP-compliant client
• Transport Layer (3 modes)
– stdio server (CLI process)
– HTTP REST server
– SSE server
• Core MCP Server
– Entry points: src/index.ts → starts one of the servers
– Route handlers (mcp-rest-server.ts, mcp-sse-server.ts, mcp-server.ts)
• Service Layer
– MediaService / Services (src/services/*.ts)
– Business logic: map MCP request → API call → format response
• API Layer
– Wrappers for MiniMax Platform endpoints (src/api/image.ts, tts.ts, video.ts, voice.ts, voice-clone.ts)
– Implements HTTP calls to remote API
• Configuration Manager
– src/config/ConfigManager.ts
– Loads from request params, CLI args, env vars, .env, default values
• Utility Modules
– src/utils/api.ts – HTTP client
– src/utils/file.ts – file I/O, basePath handling
– src/utils/audio.ts – stream/chunk helpers
• Remote Services
– MiniMax Platform REST API (Image, TTS, Video, Voice-Clone)
• Local File Store (optional)
– Written under configured basePath (downloads images/audio/video)
Relationships & Data Flow
1. MCP Client issues a request (via stdio / HTTP / SSE) →
2. Transport Layer receives request →
3. Core MCP Server delegates to Service Layer →
4. Service Layer invokes ConfigManager to resolve apiKey/apiHost/basePath/resourceMode →
5. Service calls appropriate API Layer module →
6. API Layer issues HTTP request to MiniMax Platform →
7. Platform responds with data or URLs →
8. Service Layer optionally writes local files via Utility Modules →
9. Core Server formats MCP-compliant response →
10. Transport Layer returns data to client (stream or single response)
Architectural Patterns
• Layered Architecture – clear separation: Transport → Core → Service → API → Remote
• Adapter/Wrapper Pattern – API modules adapt remote endpoints to service interface
• Strategy Pattern – three transport strategies (stdio, REST, SSE) selected at startup
• Configuration Precedence – Chain of Responsibility in ConfigManager (request → CLI → env → defaults)
Technologies & Frameworks
• Node.js + TypeScript (tsconfig.json)
• pnpm for package management
• Dockerfile for containerization (optional cloud deployment)
• HTTP/SSE libraries (built-in or third-party)
• Standard I/O for CLI integration