find
Search for files by pattern within virtual filesystem workspaces, supporting multiple storage providers and scopes.
Instructions
Find files matching a pattern.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | Yes |
Implementation Reference
- src/chuk_mcp_vfs/vfs_tools.py:320-366 (handler)The core handler function that implements the find tool logic, recursively searching directories for files matching the given pattern using fnmatch.async def find(self, request: FindRequest) -> FindResponse: """ Find files matching a pattern. Args: request: FindRequest with pattern, path, and max_results Returns: FindResponse with matching paths """ vfs = self.workspace_manager.get_current_vfs() resolved_path = self.workspace_manager.resolve_path(request.path) results: list[str] = [] truncated = False async def search(current_path: str) -> None: nonlocal truncated if len(results) >= request.max_results: truncated = True return filenames = await vfs.ls(current_path) for name in filenames: if len(results) >= request.max_results: truncated = True break # Construct full path if current_path == "/": full_path = f"/{name}" else: full_path = f"{current_path}/{name}" # Check if name matches pattern if fnmatch(name, request.pattern): results.append(full_path) # Recurse into directories node_info = await vfs.get_node_info(full_path) if node_info and node_info.is_dir: await search(full_path) await search(resolved_path) return FindResponse( pattern=request.pattern, matches=results, truncated=truncated )
- src/chuk_mcp_vfs/server.py:141-144 (registration)Registration of the 'find' tool using the @server.tool decorator, which delegates execution to the VFSTools.find method.@server.tool async def find(request: FindRequest): """Find files matching a pattern.""" return await vfs_tools.find(request)
- src/chuk_mcp_vfs/models.py:232-246 (schema)Pydantic models defining the input schema (FindRequest with pattern, path, max_results) and output schema (FindResponse with matches and truncation status) for the find tool.class FindRequest(BaseModel): """Request to find files""" pattern: str path: str = "." max_results: int = Field(default=100, ge=1, le=1000) class FindResponse(BaseModel): """Response from find operation""" pattern: str matches: list[str] truncated: bool = False