diff --git a/src/mcp_client.py b/src/mcp_client.py index e2d39a66..e5c9406f 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -221,16 +221,16 @@ def list_directory(path: str) -> str: return "; ".join(e.ui_message() for e in resolved.errors) def read_file(path: str) -> str: - """Return the UTF-8 content of a file, or an error string.""" - p, err = _resolve_and_check(path) - if err or p is None: - return err - if not p.exists(): return f"ERROR: file not found: {path}" - if not p.is_file(): return f"ERROR: not a file: {path}" - try: - return p.read_text(encoding="utf-8") - except Exception as e: - return f"ERROR reading '{path}': {e}" + """Return the UTF-8 content of a file, or an error string. + + Thin wrapper over read_file_result; the legacy str shape is preserved + for backward compatibility, but the try/except Exception lives in + the Result variant. + """ + resolved = read_file_result(path) + if resolved.ok: + return resolved.data + return "; ".join(e.ui_message() for e in resolved.errors) #region: Result Variants def _resolve_and_check_result(raw_path: str) -> Result[Path]: