MCPcopy Create free account
hub / github.com/AI45Lab/Code / check_workspace_boundary

Method check_workspace_boundary

core/src/tools/mod.rs:333–358  ·  view source on GitHub ↗
(
        name: &str,
        args: &serde_json::Value,
        ctx: &ToolContext,
    )

Source from the content-addressed store, hash-verified

331 }
332
333 fn check_workspace_boundary(
334 name: &str,
335 args: &serde_json::Value,
336 ctx: &ToolContext,
337 ) -> Result<()> {
338 let path_field = match name {
339 "read" | "write" | "edit" | "patch" => Some("file_path"),
340 "ls" | "grep" | "glob" => Some("path"),
341 _ => None,
342 };
343
344 if let Some(field) = path_field {
345 if let Some(path_str) = args.get(field).and_then(|v| v.as_str()) {
346 ctx.resolve_workspace_path(path_str).map_err(|e| {
347 anyhow::anyhow!(
348 "Workspace boundary check failed for tool '{}' path '{}': {}",
349 name,
350 path_str,
351 e
352 )
353 })?;
354 }
355 }
356
357 Ok(())
358 }
359
360 pub fn workspace(&self) -> &PathBuf {
361 &self.workspace

Callers

nothing calls this directly

Calls 3

getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected