Skip to main content
Glama

searchGlob

Find files matching a specific pattern within directories to locate code, documents, or resources using glob matching syntax.

Instructions

Search for files matching a pattern

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesThe glob pattern to match files against
pathNoThe directory to search in. Defaults to the current working directory.

Implementation Reference

  • Core implementation of the searchGlob tool. Uses the 'find' shell command to locate files matching the given pattern in the specified path.
    export async function searchGlob(
      pattern: string,
      searchPath: string = process.cwd()
    ): Promise<string[]> {
      try {
        const { stdout } = await execPromise(`find ${searchPath} -type f -name "${pattern}" | sort`);
        return stdout.trim().split('\n').filter(Boolean);
      } catch (error) {
        throw error;
      }
    }
  • Zod input schema defining parameters for the searchGlob tool: pattern (required string) and path (optional string).
    {
      pattern: z.string().describe("The glob pattern to match files against"),
      path: z.string().optional().describe("The directory to search in. Defaults to the current working directory.")
    },
  • Registration of the searchGlob tool on the MCP server using server.tool(), including description, input schema, and thin wrapper handler that calls the core searchGlob function.
      "searchGlob",
      "Search for files matching a pattern",
      {
        pattern: z.string().describe("The glob pattern to match files against"),
        path: z.string().optional().describe("The directory to search in. Defaults to the current working directory.")
      },
      async ({ pattern, path }) => {
        try {
          const results = await searchGlob(pattern, path);
          return {
            content: [{ type: "text", text: results.join('\n') }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: error instanceof Error ? error.message : String(error)
            }],
            isError: true
          };
        }
      }
    );
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 states the tool searches for files but doesn't describe how it behaves—e.g., whether it returns full paths, file contents, or metadata; if it's recursive or case-sensitive; or any performance or permission considerations. This leaves significant gaps for an agent to understand the tool's behavior.

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 directly states the tool's purpose without any fluff or redundancy. It is appropriately sized and front-loaded, making it easy for an agent to quickly grasp the core functionality.

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 file search tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a list of file paths or details), how errors are handled, or any behavioral nuances. This makes it inadequate for an agent to fully understand the tool's context and usage.

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, with clear documentation for both parameters ('pattern' and 'path'). The description adds no additional meaning beyond the schema, such as examples of glob patterns or path constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 'Search for files matching a pattern' clearly states the verb ('search') and resource ('files'), specifying the action and target. However, it doesn't distinguish this tool from sibling tools like 'grep' or 'listFiles', which might offer similar file-searching capabilities, so it lacks sibling differentiation.

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. It doesn't mention when to prefer 'searchGlob' over 'grep' for pattern matching or 'listFiles' for file listing, nor does it specify any prerequisites or exclusions for usage.

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/auchenberg/claude-code-mcp'

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