Skip to main content
Glama

grep_in_file

Match a JavaScript regex against a specific file's lines to locate exact references like URLs, hyphenated terms, or code identifiers, returning matched lines 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.
max_matchesNoCap on returned hits (default 100)
case_insensitiveNoAdd the 'i' flag (default false)
Behavior5/5

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

With no annotations provided, the description takes full responsibility for behavioral disclosure. It states the tool is read-only with no side effects, auth, or rate limits, and specifies error behavior (invalid regex throws) and response shape. This is transparent and covers safety concerns.

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 dense but efficient, front-loading the core action and constraints. Each sentence adds distinct value—scope, use cases, safety, errors, return format, and guidance—without redundancy.

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?

For a tool with no output schema, the description fully covers what the agent needs: what it does, its limitations (capped results), return structure, error behavior, and when to use it relative to siblings. It is complete enough for correct invocation.

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 coverage is 100% with descriptions for all four parameters, so the baseline is 3. The description adds minimal extra parameter-specific meaning beyond the schema, though it does clarify the regex matching context ('catches what FTS misses') and the default/max caps, which relate to max_matches. Overall, no significant additional parameter insight is provided.

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 function—matching a JS regex against one file's lines and returning line numbers—and differentiates it from siblings like regex_search (cross-file) and search (keyword/concept). The mention of catching FTS misses adds specific use-case context.

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?

Provides explicit guidance: use after read_file_outline when you know the file and need a specific reference. It also names alternatives for cross-file regex (regex_search) and keyword search (search), making the decision criteria clear.

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