Skip to main content
Glama

grep

Search file contents using regex patterns. Detects encoding, recurses directories, and can show context lines.

Instructions

Searches file contents for a regex pattern. Encoding-aware: auto-detects file encoding. Can search a single file or recursively search a directory. Output modes: content (default, matching lines), files_with_matches (paths only), count (match counts). Context: use before/after/context to include surrounding lines (like grep -B/-A/-C).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesRegular expression pattern to search for
pathNoFile or directory to search in (absolute path). Defaults to current directory
file_pathNoAlias for path
globNoGlob pattern to filter files (e.g. *.go). Only used when path is a directory
ignore_caseNoCase insensitive search: true or false. Default: false
recursiveNoRecurse into subdirectories: true or false. Default: true
max_resultsNoMaximum number of matching lines/files to return. Default: 100
output_modeNoOutput mode: 'content' (matching lines with path:line:text, default), 'files_with_matches' (file paths only), 'count' (match count per file)
contextNoLines of context before and after each match (like grep -C). Default: 0
beforeNoLines of context before each match (like grep -B). Overrides context. Default: 0
afterNoLines of context after each match (like grep -A). Overrides context. Default: 0
Behavior4/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. It discloses encoding auto-detection, recursive behavior, output modes (content, files_with_matches, count), and context line inclusion (like grep -B/-A/-C). It does not cover performance or edge cases, but these are typical for a search tool.

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 five sentences, each adding distinct information: purpose, encoding, scope, output modes, and context. No word is wasted. The structure is logical, front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 11 parameters and no output schema, the description covers all essential behavioral aspects: pattern matching, path options, glob filtering, case sensitivity, recursion, max results, output modes, and context. It does not specify default values (e.g., path defaults to current dir, recursive default true) but those are in the schema. Overall, sufficient for an agent.

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?

The input schema has 100% coverage of all 11 parameters with descriptions. The description adds value by explaining the encoding behavior, context flags (analogy to grep -B/-A/-C), and output mode string options, which are not fully captured in the schema descriptions. This bridges the gap between the schema and practical usage.

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 starts with a clear verb+resource: 'Searches file contents for a regex pattern.' This immediately distinguishes it from siblings like diff or regexreplace. The purpose is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While no explicit when-not-to-use or alternatives are mentioned, the description specifies key usage contexts: encoding-aware, single file or recursive directory, output modes, and context options. This provides enough guidance for an agent to decide when to invoke grep.

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/knewstimek/agent-tool'

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