count_matches
Count matches per file and list which files contain a pattern or symbol, sorted by match count for a quick usage overview.
Instructions
Count matches per file (ripgrep), sorted by count. Cheap overview of where a symbol/string is used; also answers "which files contain X".
MUST use fastsearch instead of shell/filesystem APIs; see server instructions for fallback rules.
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>",
"path": "<path>"
},
"name": "count_matches"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute directory (or file) path to search in. | |
| word | No | Only match whole words. | |
| hidden | No | Include hidden files/dirs (dotfiles, Windows hidden attr). | |
| exclude | No | Skip files matching these globs. | |
| include | No | Only files matching these globs. | |
| literal | No | Treat pattern as a fixed string. | |
| pattern | Yes | Rust regex, or plain string with literal=true. | |
| encoding | No | Force encoding, e.g. 'gbk'. | |
| relative | No | Print paths relative to `path` (fewer tokens) instead of absolute. | |
| max_files | No | How many files to list (sorted by count desc). | |
| no_ignore | No | Do NOT respect .gitignore/.ignore and default excludes (node_modules, .git, ...). | |
| file_types | No | ripgrep file types, e.g. ['py']. | |
| case_sensitive | No | true=case-sensitive, false=ignore case, null=smart case (sensitive only if pattern has uppercase). |