Skip to main content
Glama

grep

Search cached files for exact strings or regex patterns, returning matches with line numbers. Use for symbols, imports, or error strings in codebases.

Instructions

Search cached files for an exact string or regex, with line numbers.

This is the cache-only exact-search tool. It is intentionally closer to "ripgrep on cached content" than to live filesystem search.

Routing rules:

  • Use grep for exact symbols, literals, imports, error strings, or regex.

  • Use search for semantic or fuzzy intent.

  • Seed candidate files with batch_read first; empty results may simply mean the relevant files are not cached yet.

Usage guidance:

  • Set fixed_string=true for literals containing regex metacharacters.

  • Add path to limit scope to one file, a suffix, or a glob.

  • Add context_lines=2 or 3 when surrounding code matters.

Args: pattern: Regex pattern, or a literal if fixed_string=true. path: Optional exact path, suffix, or glob filter. fixed_string: Treat pattern as a literal instead of regex. case_sensitive: Whether matching is case-sensitive. context_lines: Number of context lines to include around matches. max_matches: Maximum total matches across all files. max_files: Maximum number of files to return.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYes
pathNo
fixed_stringNo
case_sensitiveNo
context_linesNo
max_matchesNo
max_filesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
truncatedNo
patternNo
pathNo
total_matchesNo
files_matchedNo
filesNo
fixed_stringNo
case_sensitiveNo
context_linesNo
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses cache-only behavior and approximate ripgrep nature, but could be more explicit about read-only or temporary nature. Still adds significant value.

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?

Description is well-structured with routing rules, usage guidance, and arguments list. Every sentence adds value without redundancy; front-loaded with purpose.

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 7 parameters, no annotations, and presence of output schema, the description is thorough. It covers seeding, scope limits (path), context lines, match limits, and exactly one required parameter.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds full meaning to all 7 parameters: pattern, path, fixed_string, case_sensitive, context_lines, max_matches, max_files. Provides example values and usage tips like setting fixed_string=true for literals with metacharacters.

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 'Search cached files for an exact string or regex, with line numbers' and distinguishes from sibling 'search' by specifying it's for exact matches. The routing rules reinforce this differentiation.

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?

Explicitly states when to use grep (exact symbols, literals, regex) vs search (semantic/fuzzy). Also advises seeding with batch_read to avoid empty results, providing clear context for use.

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/CoderDayton/semantic-cache-mcp'

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