Skip to main content
Glama

Search Code

search_code

Search codebases for text or regex patterns with ripgrep, noise exclusion, and optional context lines to quickly find relevant code.

Instructions

Search for a text or regex pattern across codebase with ripgrep, noise exclusion, and context lines.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "pattern": "<pattern>"
    },
    "name": "search_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoDirectory to search in (default: current directory)..
patternYesThe text or regex pattern to search for.
glob_filterNoOptional file pattern filter (e.g. '*.py', '*.ts', '*.{ts,js}').
max_resultsNoMaximum number of result lines to return.
context_linesNoNumber of surrounding context lines to show (0 = match line only).
case_sensitiveNoIf True, enforces strict case sensitivity.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.1.0
    • addedInput schema / properties / case_sensitive
      Added value: +{
      +  "default": false,
      +  "description": "If True, enforces strict case sensitivity.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / context_lines
      Added value: +{
      +  "default": 0,
      +  "description": "Number of surrounding context lines to show (0 = match line only).",
      +  "type": "integer"
      +}
    • changedInput schema / properties / path / description
      Previous value: -"Directory to search in."New value: +"Directory to search in (default: current directory)."
  2. First observedv2.0.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full burden. It hints at behavior beyond the schema with "ripgrep" and "noise exclusion," but never explains what counts as noise (gitignore? node_modules?), that the operation is read-only, or how results are truncated when max_results is hit. For a tool with zero annotation coverage this leaves important behavioral questions open.

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?

A single front-loaded sentence with no filler; the core capability leads. It is efficient, though the terseness borders on under-specification for a six-parameter tool.

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

Completeness3/5

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

An output schema exists, so return values need not be explained, and the schema fully documents parameters. What is missing is the decision context: how this differs from glob_files and run_command, and whether ignore-file behavior is applied, which matters for a codebase search tool.

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 every parameter is already documented in the schema, making 3 the baseline. The description reinforces pattern matching and context lines but adds no regex-flavor details (e.g. ripgrep's Rust regex syntax) or interaction rules such as how glob_filter composes with path.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb and resource ("Search for a text or regex pattern across codebase") and adds implementation flavor (ripgrep, noise exclusion). It does not distinguish this from siblings like glob_files (file-name matching) or run_command (which could also grep), so an agent must infer the boundary from the name alone.

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

Usage Guidelines2/5

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

There is no when-to-use guidance, no exclusions, and no mention of the natural alternatives (glob_files for filename matching, read_file for known paths). The agent gets no help deciding between this and shelling out via run_command.

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