diff --git a/README.md b/README.md index 7d1a32c..5e2bd7a 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ ### Claude Desktop Go to `Claude > Settings > Developer > Edit Config > claude_desktop_config.json` to include the following: -``` +**Option 1: Using environment variables (traditional)** +```json { "mcpServers": { "MiniMax": { @@ -71,8 +72,34 @@ Go to `Claude > Settings > Developer > Edit Config > claude_desktop_config.json` } } } +``` +**Option 2: Using CLI arguments (recommended for GitHub Copilot CLI)** +```json +{ + "mcpServers": { + "MiniMax": { + "command": "uvx", + "args": [ + "minimax-mcp", + "-y", + "--api-key=insert-your-api-key-here", + "--base-path=/User/xxx/Desktop", + "--api-host=https://api.minimax.io", + "--resource-mode=url" + ] + } + } +} ``` + +**CLI Arguments:** +- `--api-key`: MiniMax API key (overrides MINIMAX_API_KEY) +- `--base-path`: Local output directory path (overrides MINIMAX_MCP_BASE_PATH) +- `--api-host`: API host URL (overrides MINIMAX_API_HOST) +- `--resource-mode`: Resource mode [url|local] (overrides MINIMAX_API_RESOURCE_MODE) + +CLI arguments take precedence over environment variables. ⚠️ Warning: The API key needs to match the host. If an error "API Error: invalid api key" occurs, please check your api host: - Global Host:`https://api.minimax.io` - Mainland Host:`https://api.minimaxi.com` diff --git a/minimax_mcp/server.py b/minimax_mcp/server.py index c767441..0aa7568 100644 --- a/minimax_mcp/server.py +++ b/minimax_mcp/server.py @@ -12,6 +12,7 @@ """ import os +import sys import base64 import requests import time @@ -30,12 +31,27 @@ from minimax_mcp.exceptions import MinimaxAPIError, MinimaxRequestError from minimax_mcp.client import MinimaxAPIClient +# Parse CLI arguments +cli_args = {} +args = sys.argv[1:] +for i in range(len(args)): + if args[i].startswith('--'): + key_value = args[i][2:].split('=', 1) + if len(key_value) == 2: + cli_args[key_value[0]] = key_value[1] + elif i + 1 < len(args) and not args[i + 1].startswith('--'): + cli_args[key_value[0]] = args[i + 1] + +def get_config(cli_key: str, env_key: str, default: str = None) -> str: + """Get config value with CLI args taking precedence over env vars.""" + return cli_args.get(cli_key) or os.getenv(env_key) or default + load_dotenv() -api_key = os.getenv(ENV_MINIMAX_API_KEY) -base_path = os.getenv(ENV_MINIMAX_MCP_BASE_PATH) or "~/Desktop" -api_host = os.getenv(ENV_MINIMAX_API_HOST) -resource_mode = os.getenv(ENV_RESOURCE_MODE) or RESOURCE_MODE_URL -fastmcp_log_level = os.getenv(ENV_FASTMCP_LOG_LEVEL) or "WARNING" +api_key = get_config('api-key', ENV_MINIMAX_API_KEY) +base_path = get_config('base-path', ENV_MINIMAX_MCP_BASE_PATH, '~/Desktop') +api_host = get_config('api-host', ENV_MINIMAX_API_HOST) +resource_mode = get_config('resource-mode', ENV_RESOURCE_MODE, RESOURCE_MODE_URL) +fastmcp_log_level = get_config('log-level', ENV_FASTMCP_LOG_LEVEL, 'WARNING') if not api_key: raise ValueError("MINIMAX_API_KEY environment variable is required")