Skip to content

Commit 50345a3

Browse files
author
LittleCoinCoin
committed
fix(mcp): remove incorrect absolute path validation for Claude Desktop
Claude Desktop accepts both absolute and relative paths for commands, resolving them at runtime using the system PATH. The validation logic incorrectly enforced absolute path requirements that Claude Desktop itself does not have. Changes: - Remove Path.is_absolute() check from ClaudeHostStrategy.validate_server_config() - Accept any command (relative or absolute) or URL - Update test mock to match fixed behavior - Add documentation explaining Claude Desktop's actual behavior Evidence: User's working configuration contains relative path 'mamba' that was successfully synced and functions correctly in Claude Desktop. Impact: - Fixes: hatch mcp configure fails for claude-desktop with relative paths - Backward compatible: absolute paths still work - Test results: 284/286 MCP tests passing (2 unrelated failures) Root cause: Misinterpretation of Claude Desktop requirements led to overly restrictive validation that didn't match actual behavior.
1 parent 72ff2be commit 50345a3

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

hatch/mcp_host_config/strategies.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@ def get_config_key(self) -> str:
3030
return "mcpServers"
3131

3232
def validate_server_config(self, server_config: MCPServerConfig) -> bool:
33-
"""Claude family validation - requires absolute paths for local servers."""
33+
"""Claude family validation - accepts any valid command or URL.
34+
35+
Claude Desktop accepts both absolute and relative paths for commands.
36+
Commands are resolved at runtime using the system PATH, similar to
37+
how shell commands work. This validation only checks that either a
38+
command or URL is provided, not the path format.
39+
"""
40+
# Accept local servers (command-based)
3441
if server_config.command:
35-
# Claude Desktop requires absolute paths
36-
if not Path(server_config.command).is_absolute():
37-
return False
38-
return True
42+
return True
43+
# Accept remote servers (URL-based)
44+
if server_config.url:
45+
return True
46+
# Reject if neither command nor URL is provided
47+
return False
3948

4049
def _preserve_claude_settings(self, existing_config: Dict, new_servers: Dict) -> Dict:
4150
"""Preserve Claude-specific settings when updating configuration."""

tests/test_mcp_host_registry_decorator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ def __init__(self):
301301
self.config_format = "claude_format"
302302

303303
def validate_server_config(self, server_config):
304-
# Claude family requires absolute paths
305-
if server_config.command:
306-
return Path(server_config.command).is_absolute()
307-
return True
304+
# Claude family accepts any valid command or URL
305+
if server_config.command or server_config.url:
306+
return True
307+
return False
308308

309309
@register_host_strategy(MCPHostType.CLAUDE_DESKTOP)
310310
class TestClaudeDesktop(TestClaudeBase):

0 commit comments

Comments
 (0)