Skip to main content
Glama

search_code

Read-only

Search file contents by regex or literal text, returning path, line, column, and text matches. Supports context lines, per-file limits, and files-only mode for quick surveys.

Instructions

Search file contents and return structured path, line, column, and text matches. Uses ripgrep when installed and falls back to a built-in scanner otherwise. Supports surrounding context lines, a per-file match cap, and a files-only mode for cheap surveys.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoFile or directory to search; defaults to the workspace.
globsNoInclude globs such as **/*.ts, or exclude globs prefixed with "!".
literalNoTreat pattern as literal text instead of a regular expression.
patternYesRegular expression, or literal text when "literal" is true.
files_onlyNoReturn only the list of matching file paths.
timeout_msNoSearch timeout in milliseconds.
max_resultsNoMaximum returned matches.
context_linesNoLines of surrounding context to include with each match.
case_sensitiveNoUse case-sensitive matching; defaults to true.
max_matches_per_fileNoStop after this many matches in each file.
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so safety is covered. The description adds meaningful behavioral detail beyond annotations: ripgrep fallback to a built-in scanner, support for context lines, per-file cap, and files-only mode. No contradiction with annotations.

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?

Three concise sentences with no filler. The primary purpose is front-loaded, followed by relevant implementation behavior and a compact feature list. Every sentence earns its place.

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 read-only search tool with 10 params and no output schema, the description adequately conveys return format, implementation variance, and supported modes. It does not cover error/timeout behavior, but schema documents timeout_ms and max_results, so nothing critical is missing for correct invocation.

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%, with every parameter documented in the input schema. The description mentions a few high-level features (context lines, per-file cap, files-only) but adds no new semantic detail beyond what the schema already provides, so the baseline score applies.

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 states a specific verb and resource ('Search file contents') and defines the structured output (path, line, column, text matches). It is immediately distinguishable from sibling tools like find_files, which searches filenames, and read_file, which reads specific files.

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?

The description provides clear context: search file contents for code-level matches, and the files-only mode is positioned as a 'cheap survey' option. It does not explicitly name alternative tools or state when-not-to-use, but the core use case is unambiguous.

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/JonusNattapong/ChatGPTMCP'

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