GitHub file grep
github_file_grepSearch a single GitHub file with a regular expression and get line numbers plus context. Use it to pinpoint where patterns occur in one file instead of scanning whole repos.
Instructions
Search a single file's text with a regular expression and get line numbers with context. Cache-first: a warm cache costs zero upstream calls; a miss costs 1 core call. Use github_search_code for repo-wide or cross-repo search (30 requests/minute, GitHub index lag). Matching runs in a worker thread with a 2000 ms (default; GITHUB_MCP_GREP_TIMEOUT_MS) time budget; overruns degrade to matches_truncated instead of blocking the session. Returns {repo, path, ref, pattern, total_lines, matches, matches_truncated, meta}; an overrun returns no matches and carries hint instead.
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": {
"repo": "<repo>",
"path": "<path>",
"pattern": "<pattern>"
},
"name": "github_file_grep"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Branch, tag, or commit; defaults to the repository default branch | |
| path | Yes | File path inside the repository | |
| repo | Yes | Repository in owner/name form | |
| fresh | No | Bypass the local cache | |
| pattern | Yes | Regular expression (JavaScript syntax) matched globally over the file text; matches report 1-based line and column | |
| max_matches | No | Maximum number of matches to return; defaults to 50; matches_truncated reports more remained | |
| context_lines | No | Context lines before and after each match; defaults to 2 |