Skip to main content
Glama

find_file

Search for files in Godot projects using name patterns or extensions, supporting substring or regex matching to locate scenes, scripts, or resources.

Instructions

Find files by name pattern or extension in the project. Supports substring or regex matching.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesFile name pattern to search for (substring or regex)
typeNoFile type to filter byany
useRegexNoTreat pattern as a regular expression

Implementation Reference

  • Handler logic for find_file which filters file paths based on pattern (regex/substring) and type (scene/script/resource/any) by querying the system index.
    handler: async (ctx) => {
      const { pattern, type = "any", useRegex = false } = ctx.args;
    
      let matcher: (path: string) => boolean;
      if (useRegex) {
        // Reject patterns with nested quantifiers that cause catastrophic backtracking
        if (/(\+|\*|\{)\s*\??\s*[^+*?{}]*(\+|\*|\{)/.test(pattern) || pattern.length > 200) {
          return makeTextResponse({
            error:
              "Regex pattern rejected: nested quantifiers or excessive length may cause slow matching",
            data: null,
          });
        }
        try {
          const re = new RegExp(pattern);
          matcher = (p) => re.test(p);
        } catch {
          return makeTextResponse({
            error: `Invalid regex pattern: ${pattern}`,
            data: null,
          });
        }
      } else {
        matcher = (p) => p.includes(pattern);
      }
    
      const results: string[] = [];
    
      if (type === "any" || type === "scene") {
        for (const p of index.sceneIndex.allPaths()) {
          if (matcher(p)) results.push(p);
        }
      }
      if (type === "any" || type === "script") {
        for (const p of index.scriptIndex.allPaths()) {
          if (matcher(p)) results.push(p);
        }
      }
      if (type === "any" || type === "resource") {
        for (const p of index.resourceIndex.allPaths()) {
          if (matcher(p)) results.push(p);
        }
      }
    
      return makeTextResponse({
        data: results,
        totalCount: results.length,
        metadata: { source: "index" },
      });
  • Input validation schema for find_file using zod.
    schema: {
      pattern: z.string().describe("File name pattern to search for (substring or regex)"),
      type: z
        .enum(["scene", "script", "resource", "any"])
        .optional()
        .default("any")
        .describe("File type to filter by"),
      useRegex: z
        .boolean()
        .optional()
        .default(false)
        .describe("Treat pattern as a regular expression"),
    },
  • Registration of the find_file tool within the tools array.
    {
      name: "find_file",
      description:
        "Find files by name pattern or extension in the project. Supports substring or regex matching.",
      schema: {
        pattern: z.string().describe("File name pattern to search for (substring or regex)"),
        type: z
          .enum(["scene", "script", "resource", "any"])
          .optional()
          .default("any")
          .describe("File type to filter by"),
        useRegex: z
          .boolean()
          .optional()
          .default(false)
          .describe("Treat pattern as a regular expression"),
      },
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 'Supports substring or regex matching' which adds some context about search capabilities, but doesn't describe important behaviors like whether this is a read-only operation, what permissions are needed, how results are returned (e.g., list format, pagination), or any limitations (e.g., search scope, performance considerations).

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 extremely concise - just two sentences that efficiently convey the core functionality. Every word earns its place with no wasted text. It's appropriately sized for a straightforward search tool and front-loads the essential information.

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

Completeness3/5

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

For a search tool with no annotations and no output schema, the description provides basic functionality but lacks important context. It doesn't explain what the tool returns (file paths? metadata?), whether there are limitations (max results? search depth?), or how it integrates with the broader system. The 100% schema coverage helps, but behavioral aspects remain underspecified.

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?

With 100% schema description coverage, the input schema already documents all three parameters thoroughly. The description adds minimal value beyond the schema - it mentions 'name pattern or extension' and 'substring or regex matching' which aligns with the schema's parameter descriptions but doesn't provide additional semantic context or usage examples.

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 tool's purpose: 'Find files by name pattern or extension in the project.' It specifies the action (find), resource (files), and scope (in the project). However, it doesn't explicitly differentiate from sibling tools like 'find_resource' or 'find_resources_of_type', which appear to have overlapping functionality for finding resources.

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. With many sibling tools like 'find_resource', 'find_resources_of_type', and 'list_project_structure' that might overlap in file/resource discovery, there's no indication of when this specific file-finding tool is preferred or what distinguishes it from other search tools.

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/woohq/godette-mcp'

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