Skip to main content
Glama
masx200
by masx200

webdav_search_files

Search WebDAV file systems using glob patterns to find specific files and directories, with exclusion options to filter results.

Instructions

Search for files and directories using glob patterns with exclusion support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
excludePatternsNoArray of glob patterns to exclude from search results
pathNoStarting directory for the search/
patternYesGlob pattern to match files (e.g., "*.txt", "**/*.js", "config.*")

Implementation Reference

  • Full MCP tool definition including registration, input schema validation with Zod, and handler logic that delegates search to WebDAVService.searchFiles and formats the response.
    server.tool(
      "webdav_search_files",
      "Search for files and directories using glob patterns with exclusion support",
      {
        path: z.string().optional().default("/").describe(
          "Starting directory for the search",
        ),
        pattern: z.string().describe(
          'Glob pattern to match files (e.g., "*.txt", "**/*.js", "config.*")',
        ),
        excludePatterns: z.array(z.string()).optional().default([]).describe(
          "Array of glob patterns to exclude from search results",
        ),
      },
      async ({ path, pattern, excludePatterns }) => {
        try {
          const results = await webdavService.searchFiles(
            path,
            pattern,
            excludePatterns,
          );
    
          const message = results.length > 0
            ? `Found ${results.length} items matching "${pattern}":\n\n${
              results.join("\n")
            }`
            : `No items found matching "${pattern}"`;
    
          return {
            content: [{
              type: "text",
              text: message,
            }],
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error searching files: ${(error as Error).message}`,
            }],
            isError: true,
          };
        }
      },
    );
  • WebDAVService.searchFiles method: orchestrates recursive file search starting from given path using glob patterns and exclusions.
    async searchFiles(
      path: string = "/",
      pattern: string,
      excludePatterns: string[] = [],
    ): Promise<string[]> {
      const fullPath = this.getFullPath(path);
      logger.debug(`Searching for files: ${fullPath}`, {
        pattern,
        excludePatterns,
      });
    
      try {
        const results: string[] = [];
        await this._searchRecursive(
          fullPath,
          pattern,
          path,
          excludePatterns,
          results,
        );
        logger.debug(`Search completed: ${fullPath}`, {
          results: results.length,
        });
        return results;
      } catch (error) {
        logger.error(`Error searching files in ${fullPath}:`, error);
        throw new Error(`Failed to search files: ${(error as Error).message}`);
      }
    }
  • Private recursive implementation that lists directories, applies minimatch for matching and excluding paths, collects matching relative paths.
    private async _searchRecursive(
      currentPath: string,
      pattern: string,
      basePath: string,
      excludePatterns: string[],
      results: string[],
    ): Promise<void> {
      try {
        const items = await this.list(currentPath);
    
        for (const item of items) {
          const relativePath = item.filename.replace(
            this.rootPath === "/" ? "" : this.rootPath,
            "",
          );
    
          // Check if this item should be excluded
          const shouldExclude = excludePatterns.some((excludePattern) =>
            minimatch(relativePath, excludePattern, { dot: true })
          );
    
          if (shouldExclude) {
            continue;
          }
    
          // Check if this item matches the search pattern
          if (minimatch(relativePath, pattern, { dot: true })) {
            results.push(relativePath);
          }
    
          // If it's a directory, search recursively
          if (item.type === "directory") {
            await this._searchRecursive(
              item.filename,
              pattern,
              basePath,
              excludePatterns,
              results,
            );
          }
        }
      } catch (error) {
        logger.warn(`Warning: Could not access directory ${currentPath}:`, error);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'search' and 'exclusion support', but fails to detail critical aspects like whether this is a read-only operation, potential performance impacts for large directories, error handling, or output format. For a tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality ('Search for files and directories') and includes key features ('using glob patterns with exclusion support'). There is no wasted text, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search tool with no annotations and no output schema, the description is incomplete. It doesn't explain the return values (e.g., list of files, error responses), behavioral traits like read-only nature or performance considerations, or how it differs from sibling tools. For a 3-parameter tool with no structured support, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting all three parameters (pattern, path, excludePatterns) with examples for 'pattern'. The description adds value by summarizing the tool's use of 'glob patterns with exclusion support', which aligns with the schema but doesn't provide additional semantic details beyond what's already covered. Baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search for files and directories') and the method ('using glob patterns with exclusion support'), which is specific and informative. However, it doesn't explicitly distinguish this tool from sibling tools like 'webdav_list_directory_with_sizes' or 'webdav_get_directory_tree', which might also involve listing or retrieving file information, though the focus on search with patterns is implied.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as 'webdav_list_remote_directory' for simple listing or 'webdav_get_directory_tree' for hierarchical views. It mentions the search capability but lacks explicit context or exclusions, leaving usage decisions ambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/masx200/mcp-webdav-server'

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