Skip to main content
Glama

Find Files

find_files
Read-onlyIdempotent

Search for files by name or path glob under a directory when you know the pattern but not the location. Optionally match directories or include hidden and ignored entries.

Instructions

Find files whose name or path matches a glob under a directory. Use when you know a name or path pattern but not the location. Do not use it for file contents; use search_text instead. To browse a folder, use list. Matches files; type: "directory" or "any" also matches directories. Skips hidden entries, .gitignore matches, and build folders unless includeHidden or includeIgnored. Scanning stops at 10,000 matches (stoppedReason maxResults) or the time limit (FS_TOOL_TIMEOUT_MS, default 5 s; stoppedReason timeout) and still returns what it found. path must be an existing directory; a file path is rejected. maxResults sizes a page, not the scan; page on with nextCursor. Returns root, results[{ path }], totalMatches, and filesScanned. When set, it adds nextCursor, stoppedReason, skippedInaccessible, excludedDirs (total and first 5), and resourceUri (all kept matches). Paths are relative to root when unambiguous, otherwise absolute.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "pattern": "<pattern>"
    },
    "name": "find_files"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoExisting directory to search under. Required with several roots. Patterns with / match from here.
typeNoWhat to match. Directory results end in /.file
cursorNoOpaque pagination cursor. Pass it unchanged for the next page. Pages come from one snapshot taken on the first call. It lasts 5 min past its last page; on refusal, retry without it.
sortByNoname: by file name across folders, ties by path. Sorts the first 10,000 kept matches before paging.path
excludeNoGlobs for entries to leave out, with everything under a matching folder. Without / a pattern matches a name at any depth (vendor, *.test.ts); with / it matches the path relative to path.
patternYesGlob. Without / it matches file names at any depth (*.ts). With / it matches paths relative to path (src/**/*.ts).
maxDepthNoMax directory depth. 0 scans only the base directory. Omit for no limit.
maxResultsNoFiles per page; totalMatches counts all kept matches.
includeHiddenNoInclude hidden items (starting with .)
includeIgnoredNoInclude ignored items (node_modules, .git, etc).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.22.0
    • changedInput schema / properties / cursor / description
      Previous value: -"Opaque pagination cursor. Pass it unchanged for the next page. Pages come from one snapshot taken on the first call. It expires after ~60s; if rejected, retry without a cursor."New value: +"Opaque pagination cursor. Pass it unchanged for the next page. Pages come from one snapshot taken on the first call. It lasts 5 min past its last page; on refusal, retry without it."
    • addedInput schema / properties / exclude
      Added value: +{
      +  "description": "Globs for entries to leave out, with everything under a matching folder. Without / a pattern matches a name at any depth (vendor, *.test.ts); with / it matches the path relative to path.",
      +  "items": {
      +    "description": "Relative glob pattern under the search root (e.g. \"**/*.ts\", \"src/**/*.js\").",
      +    "examples": [
      +      "**/*.ts",
      +      "src/**/*.js",
      +      "**/*.{ts,tsx}"
      +    ],
      +    "maxLength": 1000,
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "maxItems": 20,
      +  "minItems": 1,
      +  "type": "array"
      +}
    • addedInput schema / properties / type
      Added value: +{
      +  "default": "file",
      +  "description": "What to match. Directory results end in /.",
      +  "enum": [
      +    "file",
      +    "directory",
      +    "any"
      +  ],
      +  "type": "string"
      +}
  2. Changed6 schema fields changedv2.20.0
    • changedInput schema / properties / cursor / description
      Previous value: -"Opaque pagination cursor; pass unchanged for the next page. Pages slice one snapshot taken on the first call; it expires after ~60s — re-request without a cursor if rejected."New value: +"Opaque pagination cursor. Pass it unchanged for the next page. Pages come from one snapshot taken on the first call. It expires after ~60s; if rejected, retry without a cursor."
    • changedInput schema / properties / maxDepth / description
      Previous value: -"Max directory depth to scan; 0 = base directory only, omit for unlimited"New value: +"Max directory depth. 0 scans only the base directory. Omit for no limit."
    • changedInput schema / properties / maxResults / description
      Previous value: -"Maximum number of matching files to return per page"New value: +"Files per page; totalMatches counts all kept matches."
    • changedInput schema / properties / path / description
      Previous value: -"Base directory to search under (default: the only root)"New value: +"Existing directory to search under. Required with several roots. Patterns with / match from here."
    • changedInput schema / properties / pattern / description
      Previous value: -"Glob pattern to match file paths (e.g. **/*.ts, src/**/*.js)"New value: +"Glob. Without / it matches file names at any depth (*.ts). With / it matches paths relative to path (src/**/*.ts)."
    • changedInput schema / properties / sortBy / description
      Previous value: -"Sort order: path = full path (default), name = basename only"New value: +"name: by file name across folders, ties by path. Sorts the first 10,000 kept matches before paging."
  3. Changed1 schema field changedv2.17.0
    • changedInput schema / properties / path / description
      Previous value: -"Base directory to search under (default: first allowed root)"New value: +"Base directory to search under (default: the only root)"
  4. Changed1 schema field changedv2.5.0
    • changedInput schema / properties / pattern / examples
      Previous value: -[
      -  "**/*.ts",
      -  "src/**/*.js",
      -  "*.{ts,tsx}"
      -]New value: +[
      +  "**/*.ts",
      +  "src/**/*.js",
      +  "**/*.{ts,tsx}"
      +]
  5. Changed2 schema fields changedv2.4.1
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / properties / pattern / examples
      Added value: +[
      +  "**/*.ts",
      +  "src/**/*.js",
      +  "*.{ts,tsx}"
      +]
  6. Addedv2.0.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, but the description adds substantial behavior beyond them: default skipping of hidden, .gitignore and build folders; a 10,000-match and time-limit scan cap that still returns partial results; rejection of a file path for `path`; and the distinction that maxResults pages rather than bounds the scan. These are the kind of gotchas an agent cannot infer from structured fields.

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

Conciseness4/5

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

Purpose and routing guidance are front-loaded before the detail, and nearly every sentence carries functional information needed because there is no output schema. It is dense and long, slightly heavier than necessary, but not padded with filler.

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

Completeness5/5

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

With no output schema, the description carries the return-value burden and does so explicitly, enumerating root, results[{ path }], totalMatches, filesScanned, and the conditional nextCursor/stoppedReason/skippedInaccessible/excludedDirs/resourceUri fields. Combined with skip rules and scan caps, it is complete for a 10-parameter search tool.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds real semantics on top: it clarifies that maxResults sizes a page and not the scan (paging via nextCursor), and that `path` must be an existing directory with file paths rejected. This reinforces subtle interactions the schema documents but does not connect.

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

Purpose5/5

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

The opening sentence gives a specific verb and resource (find files matching a glob under a directory) and immediately distinguishes it from the two closest siblings: search_text for contents and list for browsing. An agent can select this over alternatives without opening the schema.

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

Usage Guidelines5/5

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

It states the positive trigger ('when you know a name or path pattern but not the location') and explicit exclusions ('Do not use it for file contents; use search_text instead', 'To browse a folder, use list'). This is textbook when/when-not/alternative guidance.

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