diff --git a/src/mcp_client.py b/src/mcp_client.py index 0417982f..a79f7032 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -198,31 +198,15 @@ def search_files(path: str, pattern: str) -> str: """ Search for files matching a glob pattern within path. pattern examples: '*.py', '**/*.toml', 'src/**/*.rs' + + Thin wrapper over search_files_result; the legacy str shape is preserved + for backward compatibility, but the try/except Exception lives in the + Result variant (where it can capture ErrorInfo with kind=INTERNAL). """ - p, err = _resolve_and_check(path) - if err or p is None: - return err - if not p.is_dir(): - return f"ERROR: not a directory: {path}" - try: - matches = sorted(p.glob(pattern)) - if not matches: - return f"No files matched '{pattern}' in {path}" - lines = [f"Search '{pattern}' in {p}:", ""] - count = 0 - for m in matches: - # Blacklist check - name = m.name.lower() - if name == "history.toml" or name.endswith("_history.toml"): - continue - rel = m.relative_to(p) - kind = "file" if m.is_file() else "dir " - lines.append(f" [{kind}] {rel}") - count += 1 - lines.append(f" ({count} match(es))") - return "\n".join(lines) - except Exception as e: - return f"ERROR searching '{path}': {e}" + resolved = search_files_result(path, pattern) + if resolved.ok: + return resolved.data + return "; ".join(e.ui_message() for e in resolved.errors) def list_directory(path: str) -> str: """List entries in a directory. Returns a compact text table."""