search_in_files
MCP tools › Code insight and refactoring
Find text or a regular expression in the project's own source files (match case, whole words, file mask such as *.rs, *.toml). Virtual environments (.venv), installed dependencies (node_modules), build output and files ignored by Git are not searched unless include_non_project is true or directory names such a folder; not_searched says what was left out. Binary files and files over 10 MiB are skipped. Returns matches with path, 0-based line and column, end_line and end_column (0-based, just after the match; a match over a line break ends on a later line) and the text of the first line. An invalid regular expression is an error.
Its results carry text from files, language_server: the client is told to treat that as data, never as instructions.
| Capability | code.search_in_files |
|---|---|
| Area | Code insight and refactoring |
| Access | reads only |
| Reaches | — |
| Rights | none |
| Dry run | none |
Arguments
| Argument | Type | Description |
|---|---|---|
patternrequired | string | Text or regular expression. |
regex | boolean | Treat the pattern as a regular expression (default false). |
match_case | boolean | Match case (default false). |
whole_words | boolean | Whole words only (default false). |
file_mask | string | Comma-separated file-name globs, e.g. *.rs, *.toml (default: all files). |
max_matches | integer | Most matches returned (default 1000).minimum 0 |
directory | string | Only files below this workspace-relative folder or file (the Directory scope of Find in
Files, SPEC-0066 v3). A folder that is not the project's own, such as .venv/lib, is
searched completely because it is named (SPEC-0029 v2 behaviour 8). |
context | string | Where to look: anywhere (default), in_comments, in_strings, except_comments,
except_strings or except_comments_and_strings (SPEC-0066 v3 behaviour 11). |
include_non_project | boolean | Also search what is not the project's own sources: virtual environments, installed dependencies, build output, ignored files (default false; SPEC-0029 v2 behaviour 8). |
Call it from a shell
ferris-idea call runs one tool with the rights and safe mode of ferris-idea mcp. Replace the folder and the placeholder values.
ferris-idea call ~/my-project search_in_files '{"pattern":"<string>"}'Input schema as JSON
{ "type": "object", "required": [ "pattern" ], "properties": { "pattern": { "description": "Text or regular expression.", "type": "string" }, "regex": { "description": "Treat the pattern as a regular expression (default false).", "type": [ "boolean", "null" ] }, "match_case": { "description": "Match case (default false).", "type": [ "boolean", "null" ] }, "whole_words": { "description": "Whole words only (default false).", "type": [ "boolean", "null" ] }, "file_mask": { "description": "Comma-separated file-name globs, e.g. `*.rs, *.toml` (default: all files).", "type": [ "string", "null" ] }, "max_matches": { "description": "Most matches returned (default 1000).", "type": [ "integer", "null" ], "minimum": 0 }, "directory": { "description": "Only files below this workspace-relative folder or file (the Directory scope of Find in\nFiles, SPEC-0066 v3). A folder that is not the project's own, such as `.venv/lib`, is\nsearched completely because it is named (SPEC-0029 v2 behaviour 8).", "type": [ "string", "null" ] }, "context": { "description": "Where to look: `anywhere` (default), `in_comments`, `in_strings`, `except_comments`,\n`except_strings` or `except_comments_and_strings` (SPEC-0066 v3 behaviour 11).", "type": [ "string", "null" ] }, "include_non_project": { "description": "Also search what is not the project's own sources: virtual environments, installed\ndependencies, build output, ignored files (default false; SPEC-0029 v2 behaviour 8).", "type": [ "boolean", "null" ] } }}