Skip to main content
Glama

find

Locate files by pattern within virtual filesystem workspaces to manage and organize stored data across multiple storage providers.

Instructions

Find files matching a pattern.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYes

Implementation Reference

  • The core handler function for the 'find' tool. It performs a recursive directory traversal starting from the given path, matches filenames against the glob pattern using fnmatch, collects matching full paths up to max_results, and returns a FindResponse.
    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 )
  • Registration of the 'find' tool on the MCP server using the @server.tool decorator. This wrapper 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)
  • Pydantic models defining the input schema (FindRequest: pattern, path, max_results) and output schema (FindResponse: pattern, matches list, truncated flag) 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chrishayuk/chuk-mcp-vfs'

If you have feedback or need assistance with the MCP directory API, please join our Discord server