Skip to main content
Glama

search_code

Read-onlyIdempotent

Search code across all or selected repositories to locate matches by file and line, or return matched lines with surrounding context for review.

Instructions

Search code across repos. mode=locations (default) omits line text; mode=context includes context.

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": {
      "query": "<query>"
    },
    "name": "search_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNo"locations" (default) returns file+line number only; "context" also returns the matched line text and context_lines surrounding lineslocations
repoNoRepo to search: "all" searches every configured repo; otherwise a single name or comma-separated list, e.g. "pypto,simpler"all
queryYesSearch term. Treated as a fixed string unless use_regex=True
offsetNoNumber of matching lines to skip before returning results
file_globNoFilename glob filter, e.g. "*.py", "*.cc", "**/*.mlir". Default "*" matches all files.*
use_regexNoTreat query as a regular expression (ripgrep syntax). Default False uses fixed-string matching.
max_resultsNoMaximum number of match lines to return (1–2000)
context_linesNoLines of context to include around each match. Only used when mode=context.
group_by_fileNoWhen True, include a files[] list sorted by match count

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.6.0
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Number of matching lines to skip before returning results",
      +  "minimum": 0,
      +  "title": "Offset",
      +  "type": "integer"
      +}
  2. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false and openWorldHint=false, so the safety profile is fully covered. The description's only behavioral claim - that mode=locations omits line text while mode=context includes context - restates what the mode parameter's schema description already says, so it adds essentially nothing new beyond structured data.

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?

Two compact sentences with the resource statement front-loaded and the mode distinction as the single supporting detail; there is no filler. It is arguably under-informative rather than verbose, but 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?

With rich annotations, a full output schema, and 100% schema description coverage, the description only needs to flag the non-obvious mode behavior, which it does. The remaining gap is the absence of any routing hint among the many search/explain/read siblings, which an agent must infer.

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 all nine parameters (repo scoping, file_glob, use_regex, max_results, offset, context_lines, group_by_file) are documented in the schema. The description only echoes the mode default behavior on top of that, which is the correct baseline 3 when the schema does the heavy lifting.

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?

States a specific verb and resource ("Search code across repos") and immediately distinguishes its two output modes, so an agent knows it retrieves code matches rather than abstractions or docs. It does not differentiate itself from sibling tools such as search_abstractions or find_entrypoints, which is the only thing keeping it from a 5.

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

Usage Guidelines3/5

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

Usage is only implied by the scope phrase "across repos" and by the mode default; there is no explicit statement of when to choose this tool over search_abstractions, read_file, or find_entrypoints, and no exclusions or prerequisites. The mode hint guides invocation rather than tool selection, so guidance is present but thin.

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