Skip to main content
Glama

files_regex_search

Scan file bodies with a JavaScript regex to locate substrings, URLs, or code identifiers that full-text search misses. Search all files in scope or one file by ID; read-only.

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

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. Addedv6.1.2

TDQS

A4.8/5.0
Behavior5/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, and it does: read-only with 'no side effects, auth, or rate limits,' disclosed caps (500 files / 10 hits per file, 100/500 in single-file mode), the `files_truncated` cap signal, response-shape change in single-file mode, and failure mode ('Invalid regex throws'). This is unusually complete for an unannotated tool.

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?

Front-loads purpose and the routing rule, then packs caps and mode details; every sentence carries information. It is somewhat dense with parentheticals, which slightly costs readability, but nothing is wasted.

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?

Despite having no output schema, the description explains the return shape for both modes, cap behavior, and error behavior. Combined with the 100%-covered schema, an agent has everything needed to call it correctly.

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 schema already documents parameters, and the baseline would be 3. The description goes beyond by consolidating which parameters matter per mode (e.g., `project_id`/`kind` ignored when `file_id` is set) and stating the mode-dependent response shape, adding mode-selection meaning over the field-level docs.

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?

Opens with a specific verb+resource ('Match a JS regex against file bodies') and immediately distinguishes itself from the sibling FTS tool by name (`files_search`) and by why it is slower ('reads each file's content'). An agent can tell it apart from `files_search` without opening either 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?

Explicit when-to-use: 'use only when FTS misses substrings, URLs, or code identifiers,' naming the alternative (`files_search`). It also gives the distinct trigger for the second mode ('Pass `file_id` to instead scan just that one file') so the agent knows which mode to pick and when.

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