magento_grep
Search Magento code exactly: find every occurrence of a literal string or regex pattern in PHP, XML, or JS files. Returns file:line:content for each match.
Instructions
Exact text search (grep) across Magento PHP/XML/JS files. Unlike magento_search (semantic/vector), this finds EVERY occurrence of a literal string or regex pattern. Use for: finding all call sites of a method, all usages of a class name, all config references. Returns file:line:content for each match.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Subdirectory to search in (relative to MAGENTO_ROOT). Default: "." (entire codebase). Examples: "vendor/acme/", "app/code/", "vendor/magento/module-sales/" | |
| context | No | Lines of context around each match (default: 4). Like grep -C. Use 0 for broad scans with many matches, then batch-read specific files. | |
| include | No | File glob pattern to include. Default: "*.php". Examples: "*.xml", "*.{php,xml}", "*.js", "*.phtml" | *.php |
| pattern | Yes | Text pattern to search for. Literal string or POSIX regex. Examples: "getPayment()->getMethod()", "removeButton", "sales_order_place_after", "class AddressConditions" | |
| filesOnly | No | Return only file paths (like grep -l). No content, no context. Use for discovery: first find which files match, then batch-read them with magento_read. Dramatically reduces tokens when pattern matches many files. | |
| ignoreCase | No | Case-insensitive search (default: false) | |
| maxResults | No | Maximum number of matches to return (default: 50, max: 200) |