diff --git a/src/mcp_client.py b/src/mcp_client.py index c7c70a18..dd531059 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -165,17 +165,11 @@ def _is_allowed(path: Path) -> bool: # Allow current working directory and subpaths by default if no base_dirs cwd = Path.cwd().resolve() if not _base_dirs: - try: - rp.relative_to(cwd) + if rp.is_relative_to(cwd): return True - except ValueError: - pass for bd in _base_dirs: - try: - rp.relative_to(bd) + if rp.is_relative_to(bd): return True - except ValueError: - continue return False def _resolve_and_check(raw_path: str) -> tuple[Path | None, str]: