Skip to main content
Glama

Search Content

search_text
Read-only

Search file contents for literal text or regex patterns, returning matching lines with file path, line number, and column offset. Use context and file-type filters to narrow results.

Instructions

Search file contents by text or regex (grep-style). Returns matching lines with file path, 1-indexed line number and 0-indexed column offset. Set context=N to also return N lines either side of each match (grep -C). Scope to specific file types with pattern (e.g. **/*.ts). Set includeHidden=true to include dotfiles. Use find_files to search by filename instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoFile to search, or directory to search under (default: the whole first allowed root). Naming a file searches that file alone: pattern is ignored and hidden/ignored filtering does not apply.
cursorNoOpaque pagination cursor; pass unchanged for the next page. Pages slice one snapshot taken on the first call; it expires after ~60s — re-request without a cursor if rejected.
contextNoLines of context to return either side of each match, like grep -C (default: 0, max: 10)
isRegexNoTreat searchPattern as a regex (default: literal text match)
patternNoGlob to restrict search to specific file types (e.g. **/*.ts); default: all text files
maxDepthNoMax directory depth to scan; 0 = base directory only, omit for unlimited
maxResultsNoMaximum number of matching lines to return per page
caseSensitiveNoEnable case-sensitive matching (default: case-insensitive)
includeHiddenNoInclude hidden items (starting with .)
searchPatternYesExact literal text or RE2 regex pattern to search for in file contents. When isRegex=true, uses RE2 syntax (no lookahead, lookbehind, or backreferences). Cannot be empty or whitespace-only.
includeIgnoredNoInclude ignored items (node_modules, .git, etc).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.4.1
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / properties / pattern / examples
      Added value: +[
      +  "**/*.ts",
      +  "src/**/*.js",
      +  "*.{ts,tsx}"
      +]
    • addedInput schema / properties / searchPattern / examples
      Added value: +[
      +  "TODO",
      +  "function\\s+(\\w+)",
      +  "import.*from"
      +]
  2. Changed1 schema field changedv2.3.0
    • addedInput schema / properties / context
      Added value: +{
      +  "default": 0,
      +  "description": "Lines of context to return either side of each match, like grep -C (default: 0, max: 10)",
      +  "maximum": 10,
      +  "minimum": 0,
      +  "type": "integer"
      +}
  3. Addedv2.0.0

TDQS

A4.3/5.0
Behavior4/5

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

The annotations already declare readOnlyHint=true, and the description adds meaningful behavior beyond that: it specifies return shape ('matching lines with file path, 1-indexed line number and 0-indexed column offset') and context behavior. It does not mention pagination or snapshot expiration, but the cursor parameter schema covers those details, so the description is reasonably transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose and output format, then gives targeted usage examples. Each sentence serves a purpose, though a few points about context and hidden files slightly echo the schema. It remains appropriately sized for an 11-parameter tool.

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?

For a tool with no output schemaanding many parameters, the description covers the key invocation details: what is searched, what the output looks like, how to get context, how to restrict by file type, and which sibling to use instead. Remaining details like pagination and matching rules live in the schema, which is fully described.

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 description coverage is 100%, so the schema already documents all 11 parameters. The description repeats a few useful parameter semantics, such as context=N returning N lines and pattern scoping with '**/*.ts', but it does not add meaning beyond what the schema already provides. A baseline of 3 is appropriate.

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 opens with a specific verb and resource: 'Search file contents by text or regex (grep-style).' It clearly distinguishes the tool from find_files by stating 'Use find_files to search by filename instead.' This makes the tool's scope unmistakable.

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?

The description explicitly names the closest sibling alternative and the condition that routes to it: 'Use find_files to search by filename instead.' It also gives concrete usage direction for context, file-type scoping, and hidden-file inclusion, making when-to-use unambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.