Skip to main content
Glama
Reflex

Reflex

Official

search_code

Search code for text patterns and return matches with file paths, line numbers, and previews; filter by language, glob, or symbol kind and paginate results.

Instructions

Search code for a pattern: every match with path, line and preview (for path and line only, list_locations is cheaper). Whole identifiers by default; contains:true for substrings; regex:true for a Rust regex (alternation, classes, anchors; in JSON double each backslash); symbols:true for definitions only (kind narrows them). Answer: {columns, rows} (each row aligns with columns) plus pagination; when has_more, fetch the next page with offset. total_count is exact only when total_is_exact.

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
fileNoOnly paths containing this substring
globNoOnly paths matching (gitignore rules)
kindNoSymbol kind: function, struct, class, trait, …
langNoLanguage filter: rust, python, typescript, text, …
modeNocount: {count, files} only
limitNoMax results (default 200, at most 500)
pathsNoReturn file paths only
regexNoPattern is a regular expression (grep -E)
offsetNoSkip this many results (next page)
patternYesText to find
symbolsNoDefinitions only
containsNoSubstring match (grep -F) instead of whole identifiers
ignore_caseNoCase-insensitive (rg -i)
include_locksNoAlso search lock files
include_generatedNoAlso search generated files

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv2.3.1
    • removedInput schema / properties / dependencies
      Removed value: -{
      -  "description": "Attach each file's imports",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / exact
      Removed value: -{
      -  "description": "Exact symbol name",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / exclude
      Removed value: -{
      -  "description": "Skip paths matching (gitignore rules)",
      -  "items": {
      -    "type": "string"
      -  },
      -  "type": "array"
      -}
    • removedInput schema / properties / expand
      Removed value: -{
      -  "description": "Whole symbol body",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / force
      Removed value: -{
      -  "description": "Run a pattern too broad to run by default",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / preview_length
      Removed value: -{
      -  "description": "Preview characters (default 180)",
      -  "type": "integer"
      -}
    • addedInput schema / properties / regex
      Added value: +{
      +  "description": "Pattern is a regular expression (grep -E)",
      +  "type": "boolean"
      +}
  2. Changed20 schema fields changedv2.0.3
    • changedInput schema / properties / contains / description
      Previous value: -"Substring matching, like `grep -F`. DEFAULT IS FALSE, which matches WHOLE IDENTIFIERS ONLY: pattern \"verify_csrf\" does NOT match \"verify_csrf_form_field\", and \"jwks_rps\" does NOT match \"jwks_rps_limit\". Pass true to find a pattern anywhere inside a longer identifier. If a search returns 0, check the response `hint` — it reports how many substring matches exist."New value: +"Substring match (grep -F) instead of whole identifiers"
    • changedInput schema / properties / dependencies / description
      Previous value: -"Include dependency information (imports) in results. **IMPORTANT:** Currently only supported for Rust files — passing this with any other language (typescript, python, go, etc.) will produce no dependency data. Only extracts static imports (string literals); dynamic imports are filtered. See CLAUDE.md for details."New value: +"Attach each file's imports"
    • changedInput schema / properties / exact / description
      Previous value: -"Case-sensitive exact-identifier match. NOTE: substring matching is already OFF by default — use `contains: true` to turn it ON, not this flag."New value: +"Exact symbol name"
    • changedInput schema / properties / exclude / description
      Previous value: -"Exclude files matching glob patterns (e.g., 'target/**') Patterns follow gitignore rules: a pattern containing '/' (src/**/*.rs) is anchored at the index root; a bare name (*.rs, Makefile) matches at any depth; **/src/**/*.rs matches src/ anywhere; * does not cross /."New value: +"Skip paths matching (gitignore rules)"
    • changedInput schema / properties / expand / description
      Previous value: -"Show full symbol body (not just signature)"New value: +"Whole symbol body"
    • changedInput schema / properties / file / description
      Previous value: -"Filter by file path (substring)"New value: +"Only paths containing this substring"
    • changedInput schema / properties / force / description
      Previous value: -"Force execution of potentially expensive queries (bypasses broad query detection)"New value: +"Run a pattern too broad to run by default"
    • changedInput schema / properties / glob / description
      Previous value: -"Include files matching glob patterns (e.g., 'src/**/*.rs') Patterns follow gitignore rules: a pattern containing '/' (src/**/*.rs) is anchored at the index root; a bare name (*.rs, Makefile) matches at any depth; **/src/**/*.rs matches src/ anywhere; * does not cross /."New value: +"Only paths matching (gitignore rules)"
    • changedInput schema / properties / ignore_case / description
      Previous value: -"Match letters regardless of case, like `rg -i` (`ignore_case` + `contains` is `rg -i -F`). Default false. The trigram index is still used, so this costs about the same as a case-sensitive search."New value: +"Case-insensitive (rg -i)"
    • changedInput schema / properties / include_generated / description
      Previous value: -"Also search generated files by name (*.pb.go, *.min.js, *.min.css, *.map, *_generated.*). Indexed but left out unless asked for; `lang: \"generated\"` selects them alone. Default false."New value: +"Also search generated files"
    • changedInput schema / properties / include_locks / description
      Previous value: -"Also search lock files (Cargo.lock, package-lock.json, *.lock, go.sum). They are indexed but left out unless asked for; `lang: \"lock\"` selects them alone. Default false."New value: +"Also search lock files"
    • changedInput schema / properties / kind / description
      Previous value: -"Filter by symbol kind (function, class, struct, etc.)"New value: +"Symbol kind: function, struct, class, trait, …"
    • changedInput schema / properties / lang / description
      Previous value: -"Filter by language: rust, typescript, javascript, go, java, php, kotlin, python, c, cpp, csharp, ruby, vue, svelte, zig — or \"text\" for the plain-text tier (every other non-binary file: docs, config, templates, extensionless), \"lock\" for lock files, \"generated\" for generated files (the last two are excluded unless named or include_locks / include_generated is set)."New value: +"Language filter: rust, python, typescript, text, …"
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum results per page (default: 200, max: 500). The 200-result default covers most find-all tasks in a single call. IMPORTANT: If response.has_more is true, you MUST fetch more pages using offset parameter."New value: +"Max results (default 200, at most 500)"
    • changedInput schema / properties / mode / description
      Previous value: -"Response mode: \"list\" (default) returns full match results; \"count\" returns only {count, pattern} — faster, skips match body serialization."New value: +"count: {count, files} only"
    • changedInput schema / properties / offset / description
      Previous value: -"Pagination offset (skip first N results). ALWAYS paginate when has_more=true. Example: First call offset=0, second call offset=100, third offset=200, etc."New value: +"Skip this many results (next page)"
    • changedInput schema / properties / paths / description
      Previous value: -"Return only unique file paths: the response is `{status, can_trust_results, paths, total_files}` (plus `has_more` when a `limit` cut the list) instead of `{columns, rows}`. Without `limit`, every matching file is listed."New value: +"Return file paths only"
    • changedInput schema / properties / pattern / description
      Previous value: -"Search pattern (text to find)"New value: +"Text to find"
    • changedInput schema / properties / preview_length / description
      Previous value: -"Maximum characters per preview line (default: 180). Use a smaller value (e.g. 60) for wide-result scans where short previews are sufficient."New value: +"Preview characters (default 180)"
    • changedInput schema / properties / symbols / description
      Previous value: -"Symbol-only search (definitions, not usage)"New value: +"Definitions only"
  3. Changed9 schema fields changedv2.0.1
    • addedInput schema / properties / contains
      Added value: +{
      +  "description": "Substring matching, like `grep -F`. DEFAULT IS FALSE, which matches WHOLE IDENTIFIERS ONLY: pattern \"verify_csrf\" does NOT match \"verify_csrf_form_field\", and \"jwks_rps\" does NOT match \"jwks_rps_limit\". Pass true to find a pattern anywhere inside a longer identifier. If a search returns 0, check the response `hint` — it reports how many substring matches exist.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / exact / description
      Previous value: -"Exact match (no substring matching)"New value: +"Case-sensitive exact-identifier match. NOTE: substring matching is already OFF by default — use `contains: true` to turn it ON, not this flag."
    • changedInput schema / properties / exclude / description
      Previous value: -"Exclude files matching glob patterns (e.g., 'target/**')"New value: +"Exclude files matching glob patterns (e.g., 'target/**') Patterns follow gitignore rules: a pattern containing '/' (src/**/*.rs) is anchored at the index root; a bare name (*.rs, Makefile) matches at any depth; **/src/**/*.rs matches src/ anywhere; * does not cross /."
    • changedInput schema / properties / glob / description
      Previous value: -"Include files matching glob patterns (e.g., 'src/**/*.rs')"New value: +"Include files matching glob patterns (e.g., 'src/**/*.rs') Patterns follow gitignore rules: a pattern containing '/' (src/**/*.rs) is anchored at the index root; a bare name (*.rs, Makefile) matches at any depth; **/src/**/*.rs matches src/ anywhere; * does not cross /."
    • addedInput schema / properties / ignore_case
      Added value: +{
      +  "description": "Match letters regardless of case, like `rg -i` (`ignore_case` + `contains` is `rg -i -F`). Default false. The trigram index is still used, so this costs about the same as a case-sensitive search.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / include_generated
      Added value: +{
      +  "description": "Also search generated files by name (*.pb.go, *.min.js, *.min.css, *.map, *_generated.*). Indexed but left out unless asked for; `lang: \"generated\"` selects them alone. Default false.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / include_locks
      Added value: +{
      +  "description": "Also search lock files (Cargo.lock, package-lock.json, *.lock, go.sum). They are indexed but left out unless asked for; `lang: \"lock\"` selects them alone. Default false.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / lang / description
      Previous value: -"Filter by language (rust, typescript, python, etc.)"New value: +"Filter by language: rust, typescript, javascript, go, java, php, kotlin, python, c, cpp, csharp, ruby, vue, svelte, zig — or \"text\" for the plain-text tier (every other non-binary file: docs, config, templates, extensionless), \"lock\" for lock files, \"generated\" for generated files (the last two are excluded unless named or include_locks / include_generated is set)."
    • changedInput schema / properties / paths / description
      Previous value: -"Return only unique file paths (not full results)"New value: +"Return only unique file paths: the response is `{status, can_trust_results, paths, total_files}` (plus `has_more` when a `limit` cut the list) instead of `{columns, rows}`. Without `limit`, every matching file is listed."
  4. Changed2 schema fields changedv1.6.0
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum results per page (default: 100). IMPORTANT: If response.pagination.has_more is true, you MUST fetch more pages using offset parameter."New value: +"Maximum results per page (default: 200, max: 500). The 200-result default covers most find-all tasks in a single call. IMPORTANT: If response.has_more is true, you MUST fetch more pages using offset parameter."
    • addedInput schema / properties / mode
      Added value: +{
      +  "description": "Response mode: \"list\" (default) returns full match results; \"count\" returns only {count, pattern} — faster, skips match body serialization.",
      +  "enum": [
      +    "list",
      +    "count"
      +  ],
      +  "type": "string"
      +}
  5. First observedv1.0.0

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden, and it does well: it discloses the return shape ({columns, rows}), pagination behavior via has_more/offset, and the caveat that total_count is exact only when total_is_exact. It omits details such as result ordering or permission expectations, but for a read-only search tool this is substantially 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 dense but front-loaded, leading with the core purpose and match format before detailing modes and pagination. The semicolon-heavy parentheticals make it slightly harder to scan, but every clause contributes useful information.

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

Completeness5/5

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

There is no output schema, yet the description explains the return structure and pagination contract, and the 15-parameter schema is fully documented. An agent has enough information to invoke the tool correctly and interpret its response.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaningful semantics beyond the schema: whole identifiers are the default, contains:true enables substrings, regex:true uses Rust regex with JSON backslash escaping, and symbols:true restricts to definitions narrowed by kind. These distinctions help an agent choose flags correctly.

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 code for a pattern', and immediately states what each match contains (path, line, preview). It also distinguishes itself from list_locations by explaining the cheaper alternative for path/line-only needs.

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?

It names a concrete alternative, list_locations, and the condition under which that alternative is cheaper. It also explains the main search modes (whole identifier, substring, regex, symbol definitions), though it does not address when to prefer other siblings like find_references or analyze.

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