Skip to main content
Glama

grep_in_file

Match a regex pattern against a file's lines and retrieve matched lines with line numbers, capturing what full-text search misses like URLs and code identifiers.

Instructions

Match a JS regex against one file's lines and return matched lines with line numbers (capped: default 100, max 500). Catches what FTS misses: URLs, hyphenated terms, code identifiers. Read-only; no side effects, auth, or rate limits. Invalid regex throws invalid regex. Returns {matches, match_count, truncated}. Use after read_file_outline when you know the file but need a specific reference; for cross-file regex use regex_search; for keyword/concept search use search.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesFile ID
patternYesPattern to match. Treated as a JavaScript RegExp source.
case_insensitiveNoAdd the 'i' flag (default false)
max_matchesNoCap on returned hits (default 100)
Behavior5/5

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

The description discloses all behavioral traits: 'Read-only; no side effects, auth, or rate limits. Invalid regex throws invalid regex.' It also specifies the return format. Since no annotations are provided, the description fully covers transparency.

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 concise: three sentences covering purpose, unique value, and usage guidelines. No redundant information.

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 no output schema, the description fully explains the return format and error behavior. It also provides usage context. All aspects are covered.

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 baseline is 3. The description adds context beyond the schema by explaining the regex origin ('JS') and noting what the tool catches: 'URLs, hyphenated terms, code identifiers.' It also reinforces defaults and caps.

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 description clearly states the tool's action: 'Match a JS regex against one file's lines and return matched lines with line numbers.' It specifies the resource (file lines) and distinguishes from siblings by mentioning alternatives for cross-file regex and keyword search.

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 usage guidelines are provided: 'Use after read_file_outline when you know the file but need a specific reference; for cross-file regex use regex_search; for keyword/concept search use search.' This clearly indicates when to use this tool and when to use alternatives.

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/safiyu/ctxnest'

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