Skip to main content

validate_local_path

Function validate_local_path 

Source
pub fn validate_local_path(path: &str) -> Result<PathBuf, McpError>
Expand description

Validate a LocalFile path. Must be absolute, must exist, must canonicalize cleanly with no .. components in the result. Returns the canonical path on success.

§Errors

  • Returns ErrorCode::InvalidArgument if path is relative or if the canonicalized path contains .. components (symlink escape).
  • Returns ErrorCode::FileNotFound if std::fs::canonicalize fails — typically because the file does not exist or a parent directory is not traversable.