search_code
Search file contents across the repository to find matching lines with file:line locations, using regex, glob filters, and context.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Restrict the search to this subdirectory. | |
| regex | No | Treat pattern as a regular expression. Default false (literal). | |
| exclude | No | Skip files matching these globs. | |
| include | No | Only search files matching these globs, e.g. ["**/*.java", "src/**/*.ts"]. | |
| pattern | Yes | Text to find, or a regular expression when regex=true. | |
| workspace | No | Workspace alias. Defaults to the active workspace. | |
| max_results | No | Default 100, max 1000. | |
| context_lines | No | Lines of context around each match, 0-10. Default 0. | |
| case_sensitive | No | Default false. |