fix: Windows PATH detection for CLI tools in PowerShell environments

- Add shell=True parameter to subprocess.run() calls on Windows platform
- Fixes issue #128 where Claude CLI, Node.js, and npm were not detected in PowerShell
- Affects validator.py and mcp.py components for better Windows compatibility
- Resolves PowerShell PATH inheritance issues with Python subprocess

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NomenAK 2025-07-14 21:11:28 +02:00
parent f975070946
commit b9fac065e0
2 changed files with 27 additions and 14 deletions

View File

@ -3,6 +3,7 @@ MCP component for MCP server integration
""" """
import subprocess import subprocess
import sys
import json import json
from typing import Dict, List, Tuple, Any from typing import Dict, List, Tuple, Any
from pathlib import Path from pathlib import Path
@ -75,7 +76,8 @@ class MCPComponent(Component):
["node", "--version"], ["node", "--version"],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=10 timeout=10,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
errors.append("Node.js not found - required for MCP servers") errors.append("Node.js not found - required for MCP servers")
@ -99,7 +101,8 @@ class MCPComponent(Component):
["claude", "--version"], ["claude", "--version"],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=10 timeout=10,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
errors.append("Claude CLI not found - required for MCP server management") errors.append("Claude CLI not found - required for MCP server management")
@ -115,7 +118,8 @@ class MCPComponent(Component):
["npm", "--version"], ["npm", "--version"],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=10 timeout=10,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
errors.append("npm not found - required for MCP server installation") errors.append("npm not found - required for MCP server installation")
@ -160,7 +164,8 @@ class MCPComponent(Component):
["claude", "mcp", "list"], ["claude", "mcp", "list"],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=15 timeout=15,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
@ -218,7 +223,8 @@ class MCPComponent(Component):
["claude", "mcp", "add", server_name, command], ["claude", "mcp", "add", server_name, command],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=120 # 2 minutes timeout for installation timeout=120, # 2 minutes timeout for installation
shell=(sys.platform == "win32")
) )
if result.returncode == 0: if result.returncode == 0:
@ -252,7 +258,8 @@ class MCPComponent(Component):
["claude", "mcp", "remove", server_name], ["claude", "mcp", "remove", server_name],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=60 timeout=60,
shell=(sys.platform == "win32")
) )
if result.returncode == 0: if result.returncode == 0:
@ -328,7 +335,8 @@ class MCPComponent(Component):
["claude", "mcp", "list"], ["claude", "mcp", "list"],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=15 timeout=15,
shell=(sys.platform == "win32")
) )
if result.returncode == 0: if result.returncode == 0:
@ -470,7 +478,8 @@ class MCPComponent(Component):
["claude", "mcp", "list"], ["claude", "mcp", "list"],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=15 timeout=15,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:

View File

@ -114,12 +114,13 @@ class Validator:
return self.validation_cache[cache_key] return self.validation_cache[cache_key]
try: try:
# Check if node is installed # Check if node is installed - use shell=True on Windows for better PATH resolution
result = subprocess.run( result = subprocess.run(
['node', '--version'], ['node', '--version'],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=10 timeout=10,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
@ -181,12 +182,13 @@ class Validator:
return self.validation_cache[cache_key] return self.validation_cache[cache_key]
try: try:
# Check if claude is installed # Check if claude is installed - use shell=True on Windows for better PATH resolution
result = subprocess.run( result = subprocess.run(
['claude', '--version'], ['claude', '--version'],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=10 timeout=10,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
@ -254,7 +256,8 @@ class Validator:
cmd_parts, cmd_parts,
capture_output=True, capture_output=True,
text=True, text=True,
timeout=10 timeout=10,
shell=(sys.platform == "win32")
) )
if result.returncode != 0: if result.returncode != 0:
@ -651,7 +654,8 @@ class Validator:
["which" if sys.platform != "win32" else "where", tool], ["which" if sys.platform != "win32" else "where", tool],
capture_output=True, capture_output=True,
text=True, text=True,
timeout=5 timeout=5,
shell=(sys.platform == "win32")
) )
if result.returncode == 0: if result.returncode == 0:
tool_found = True tool_found = True