search_code
Search entire codebase for text patterns, returning file paths, line numbers, and code previews. Supports symbol definitions and usage counts.
Instructions
Default code search across the whole codebase. Prefer this over Grep / grep -rn / Glob for any pattern made of letters, digits, underscores, or hyphens — one call returns every occurrence with file paths, line numbers, and code previews. Use this for: finding where a pattern occurs; listing all usages of a function/class/variable; finding a symbol's definition (with symbols: true); getting line numbers + previews in a single call.
Modes: full-text by default (definitions + usages); symbols: true returns definitions only; mode: "count" returns just {count, pattern} to check cardinality before paginating. For patterns containing special characters (->, ::, (), [], .*+?\|^$), use search_regex instead.
Result shape is columnar: {columns, rows} — each row aligns positionally to columns (path, language, start_line, end_line, preview; then kind/symbol/context when present). Set env REFLEX_MCP_COLUMNAR=0 for the legacy results[] shape.
Pagination: if response.pagination.has_more is true, fetch the next page with the offset parameter. On "Index not found" / "stale" error, call index_project, then retry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | No | Filter by file path (substring) | |
| glob | No | Include files matching glob patterns (e.g., 'src/**/*.rs') | |
| kind | No | Filter by symbol kind (function, class, struct, etc.) | |
| lang | No | Filter by language (rust, typescript, python, etc.) | |
| mode | No | Response mode: "list" (default) returns full match results; "count" returns only {count, pattern} — faster, skips match body serialization. | |
| exact | No | Exact match (no substring matching) | |
| force | No | Force execution of potentially expensive queries (bypasses broad query detection) | |
| limit | No | 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. | |
| paths | No | Return only unique file paths (not full results) | |
| expand | No | Show full symbol body (not just signature) | |
| offset | No | 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. | |
| exclude | No | Exclude files matching glob patterns (e.g., 'target/**') | |
| pattern | Yes | Search pattern (text to find) | |
| symbols | No | Symbol-only search (definitions, not usage) | |
| dependencies | No | 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. | |
| preview_length | No | Maximum characters per preview line (default: 180). Use a smaller value (e.g. 60) for wide-result scans where short previews are sufficient. |