Skip to main content
Glama

grep_in_file

Search a file's lines with a JS regex to locate specific references (e.g., URLs, code identifiers) that full-text search misses, returning matches with line numbers.

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?

No annotations provided, so description carries full burden. It states read-only, no side effects, auth, or rate limits. It also discloses error behavior: 'Invalid regex throws invalid regex' and return shape: {matches, match_count, truncated}. This fully informs the agent of behavioral traits.

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?

5 sentences, front-loaded with core action, no redundant information. Every sentence adds value, and the structure is logical.

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?

No output schema, but description includes return shape and cap behavior. Explains use case, limitations, and relationship to sibling tools. Complete for a 4-parameter tool with no output schema.

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 covers all 4 parameters with descriptions (100% coverage). The description adds context on max_matches default (100) and max (500) which is already in schema, and mentions default for case_insensitive implicitly. It adds error behavior for pattern and return structure, providing additional value beyond the schema.

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 matches a JS regex against one file's lines and returns matched lines with line numbers. It distinguishes from siblings by noting it catches what FTS misses and explicitly mentions alternatives for cross-file regex (regex_search) and keyword search (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 guidance on when to use: 'Use after read_file_outline when you know the file but need a specific reference.' Also provides clear alternatives: 'for cross-file regex use regex_search; for keyword/concept search use search.'

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/kontexta'

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