Skip to main content
Glama

files.regex_search

Find exact regex matches in file contents with line numbers. Use when full-text search misses substrings, URLs, or code identifiers; optionally scan a single known file.

Instructions

Match a JS regex against file bodies. Default mode scans every file in scope (project, KB, or all) and returns per-file hits with line numbers — slower than FTS files.search because it reads each file's content; use only when FTS misses substrings, URLs, or code identifiers. Pass file_id to instead scan just that one file (catches what FTS misses within a single known file); response shape changes to {file_id, path, pattern, match_count, truncated, matches}. Read-only; no side effects, auth, or rate limits. Multi-file mode capped at 500 files / 10 hits per file by default (files_truncated reports the cap); single-file mode capped at 100 hits by default, max 500. project_id/kind are ignored when file_id is set. Invalid regex throws.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindNoFilter by content class before scanning. Ignored when `file_id` is set.
file_idNoScan only this file instead of every file in scope. When set, `project_id`/`kind`/`max_files`/`max_matches_per_file` are ignored in favor of `max_matches`.
patternYesJavaScript RegExp source
max_filesNoCap on files scanned (default 500). Ignored when `file_id` is set.
project_idNoScope to one project, null for KB-only, omit for everything. Ignored when `file_id` is set.
max_matchesNoCap on returned hits in single-file mode (default 100). Only used when `file_id` is set.
case_insensitiveNoIf true, match pattern case-insensitively (RegExp 'i' flag). Default false.
max_matches_per_fileNoPer-file hit cap in multi-file mode (default 10). Ignored when `file_id` is set.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv5.0.0
    • addedInput schema / properties / file_id
      Added value: +{
      +  "description": "Scan only this file instead of every file in scope. When set, `project_id`/`kind`/`max_files`/`max_matches_per_file` are ignored in favor of `max_matches`.",
      +  "type": "number"
      +}
    • changedInput schema / properties / kind / description
      Previous value: -"Filter by content class before scanning."New value: +"Filter by content class before scanning. Ignored when `file_id` is set."
    • changedInput schema / properties / max_files / description
      Previous value: -"Cap on files scanned (default 500)"New value: +"Cap on files scanned (default 500). Ignored when `file_id` is set."
    • addedInput schema / properties / max_matches
      Added value: +{
      +  "description": "Cap on returned hits in single-file mode (default 100). Only used when `file_id` is set.",
      +  "exclusiveMinimum": 0,
      +  "maximum": 500,
      +  "type": "integer"
      +}
    • changedInput schema / properties / max_matches_per_file / description
      Previous value: -"Per-file hit cap (default 10)"New value: +"Per-file hit cap in multi-file mode (default 10). Ignored when `file_id` is set."
    • changedInput schema / properties / project_id / description
      Previous value: -"Scope to one project, null for KB-only, omit for everything"New value: +"Scope to one project, null for KB-only, omit for everything. Ignored when `file_id` is set."
  2. Addedv4.7.2

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explicitly states that the tool is read-only with no side effects, auth, or rate limits. It also discloses the caps on results (500 files / 10 hits per file in multi-file mode, 100 hits default in single-file mode) and the error behavior for invalid regex. It could also mention that single-file mode changes the response shape, which it does. This is thorough, though not perfect—perhaps missing details on performance impact or response format, but sufficient.

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 well-structured and front-loaded with the core purpose. It uses three paragraphs that flow logically: the main function and when to use it, the single-file mode variant, and caps/behavioral details. Every sentence adds value, and there is no redundancy. The key caveats (slower than FTS, response shape change, caps) are placed prominently. This is a model of concise yet comprehensive tool description.

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?

Given the tool's complexity (8 parameters, two modes, multiple caps, error behavior), the description is remarkably complete. It covers the default behavior, the single-file mode, parameter interactions, caps, and error handling. Since there is no output schema, the description explains the response shape change for single-file mode. The only minor omission is a more detailed description of the multi-file response shape, but the description hints at per-file hits with line numbers. Overall, nothing critical is missing for an agent to call it correctly.

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?

Schema description coverage is 100%, so the schema already documents each parameter with details like 'Ignored when file_id is set' and 'Default false'. The description adds value by clarifying the modes and the interaction between parameters (e.g., `project_id`/`kind` ignored when `file_id` is set, `max_matches` only used in single-file mode). However, it doesn't provide additional semantics beyond what's in the schema, but the baseline is 3 because the schema is thorough, and the description reinforces it.

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 function: matches a JS regex against file bodies, with a clear distinction between multi-file and single-file modes. It names the sibling `files.search` and explains when to use this tool instead. It could be stronger by explicitly stating that it is a regex search tool, but the verb 'Match' and resource 'file bodies' are specific enough.

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?

The description provides explicit guidance on when to use this tool versus the FTS `files.search`, emphasizing that regex search is slower and should only be used when FTS misses substrings, URLs, or code identifiers. It also explains the two modes (default multi-file and single-file with `file_id`), and notes that `project_id`/`kind` are ignored in single-file mode. This is comprehensive and leaves no ambiguity.

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