Fix MCP server installation by adding proper command format

The Claude CLI requires both name and command parameters for 'mcp add':
claude mcp add <name> <commandOrUrl>

This commit:
- Adds 'command' field to all MCP server definitions
- Updates _install_mcp_server to use both server name and command
- Fixes the subprocess call to include both required parameters

Fixes: Failed to install MCP server sequential-thinking: error: missing required argument 'commandOrUrl'

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NomenAK 2025-07-14 16:02:08 +02:00
parent 8c5fad9875
commit 952b177598

View File

@ -28,18 +28,21 @@ class MCPComponent(Component):
"name": "sequential-thinking",
"description": "Multi-step problem solving and systematic analysis",
"npm_package": "@modelcontextprotocol/server-sequential-thinking",
"command": "npx @modelcontextprotocol/server-sequential-thinking",
"required": True
},
"context7": {
"name": "context7",
"description": "Official library documentation and code examples",
"npm_package": "@context7/mcp",
"command": "npx @context7/mcp",
"required": True
},
"magic": {
"name": "magic",
"description": "Modern UI component generation and design systems",
"npm_package": "@21st/mcp",
"command": "npx @21st/mcp",
"required": False,
"api_key_env": "TWENTYFIRST_API_KEY",
"api_key_description": "21st.dev API key for UI component generation"
@ -48,6 +51,7 @@ class MCPComponent(Component):
"name": "playwright",
"description": "Cross-browser E2E testing and automation",
"npm_package": "@modelcontextprotocol/server-playwright",
"command": "npx @modelcontextprotocol/server-playwright",
"required": False
}
}
@ -171,6 +175,9 @@ class MCPComponent(Component):
server_name = server_info["name"]
npm_package = server_info["npm_package"]
# Get the command to use - either specified in server_info or default to npx format
command = server_info.get("command", f"npx {npm_package}")
try:
self.logger.info(f"Installing MCP server: {server_name}")
@ -197,13 +204,13 @@ class MCPComponent(Component):
# Install using Claude CLI
if config.get("dry_run", False):
self.logger.info(f"Would install MCP server: claude mcp add {npm_package}")
self.logger.info(f"Would install MCP server: claude mcp add {server_name} {command}")
return True
self.logger.debug(f"Running: claude mcp add {npm_package}")
self.logger.debug(f"Running: claude mcp add {server_name} {command}")
result = subprocess.run(
["claude", "mcp", "add", npm_package],
["claude", "mcp", "add", server_name, command],
capture_output=True,
text=True,
timeout=120 # 2 minutes timeout for installation