Skip to main content
Glama

grep

Search file contents for regex patterns with encoding detection, directory recursion, and context options to find specific text in files.

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
globNoGlob pattern to filter files (e.g. *.go). Only used when path is a directory
ignore_caseNoCase insensitive search (default false)
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

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