MCPcopy Create free account
hub / github.com/bcefghj/miniClaudeCode / execute

Method execute

miniclaudecode/tools/glob_tool.py:42–63  ·  view source on GitHub ↗
(self, params: dict[str, Any])

Source from the content-addressed store, hash-verified

40 }
41
42 def execute(self, params: dict[str, Any]) -> ToolResult:
43 pattern = params["pattern"]
44 directory = Path(params.get("directory", ".")).expanduser().resolve()
45
46 if not directory.is_dir():
47 return ToolResult(output=f"Error: directory not found: {directory}", is_error=True)
48
49 if not pattern.startswith("**/") and "/" not in pattern:
50 pattern = f"**/{pattern}"
51
52 try:
53 matches = sorted(directory.glob(pattern), key=lambda p: p.stat().st_mtime, reverse=True)
54 except Exception as exc:
55 return ToolResult(output=f"Error: {exc}", is_error=True)
56
57 if not matches:
58 return ToolResult(output="No files matched.")
59
60 lines = [str(p) for p in matches[:MAX_RESULTS]]
61 if len(matches) > MAX_RESULTS:
62 lines.append(f"... and {len(matches) - MAX_RESULTS} more")
63 return ToolResult(output="\n".join(lines))

Callers

nothing calls this directly

Calls 2

ToolResultClass · 0.85
getMethod · 0.80

Tested by

no test coverage detected