Skip to main content
Glama

search_code

Locate code in a repository by searching file contents, returning file:line matches. Supports literal or regex patterns, glob filters, and context lines.

Instructions

Search file contents across the repository and return matching lines with file:line locations. This is the primary way to find code — far cheaper than reading files. Supports literal or regex patterns, glob filters, and surrounding context lines. Respects .gitignore.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoRestrict the search to this subdirectory.
regexNoTreat pattern as a regular expression. Default false (literal).
excludeNoSkip files matching these globs.
includeNoOnly search files matching these globs, e.g. ["**/*.java", "src/**/*.ts"].
patternYesText to find, or a regular expression when regex=true.
workspaceNoWorkspace alias. Defaults to the active workspace.
max_resultsNoDefault 100, max 1000.
context_linesNoLines of context around each match, 0-10. Default 0.
case_sensitiveNoDefault false.
Behavior4/5

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

With no annotations, the description carries the burden of behavioral disclosure. It adds useful traits: returning file:line locations, supporting literal/regex and glob filters, providing context lines, and respecting .gitignore. It does not explicitly state read-only behavior, but the search semantics imply no mutation, and the additional context makes the behavior fairly transparent.

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 three sentences with no fluff. It front-loads the primary purpose and output, then adds a usage hint, capabilities, and behavioral note. Every sentence earns its place, achieving high information density in a compact structure.

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?

Given the absence of an output schema, the description adequately covers the return format (file:line locations) and key behaviors (filters, context, .gitignore). It does not mention limits like max_results or potential truncation, but those are documented in the schema. Overall, it provides enough context for an agent to use the tool effectively.

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?

The schema has 100% parameter description coverage, so the baseline is 3. The description reinforces that the pattern can be literal or regex and mentions glob filters and context lines, but these map directly to existing schema descriptions. It adds no new parameter-specific meaning beyond what the schema already provides.

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 clearly defines the verb ('Search'), resource ('file contents across the repository'), and output ('return matching lines with file:line locations'). It also distinguishes from siblings by emphasizing it searches file contents rather than filenames and states it is the 'primary way to find code.'

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 on when to use this tool: 'This is the primary way to find code — far cheaper than reading files.' This implies it should be used instead of reading files for code search, but it does not explicitly name alternative tools like find_files or state exclusions, so it stops short of full guidance.

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/zcrossoverz/repo-bridge'

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