search_repo_context
Search a repository by keywords to rank likely relevant files and return bounded snippets around the strongest matches, letting you narrow a large codebase before deeper inspection.
Instructions
Search a repository with explicit keywords, rank likely relevant files without reading full files, and return bounded snippets around the strongest clustered matches. The tool prefers source files over docs when scores are similar, boosts likely function, class, struct, module, or method definition hits, merges overlapping match windows, and enforces hard budgets on returned files, snippets, and total lines. Optional subtree and glob filters can narrow the search space before ranking. Matching defaults to substring mode, with optional word and identifier-aware modes for stricter code search. Keyword expansion is bounded and returned transparently in the output. Prefer specific keywords over very general ones; ranking gives substantially more weight to matches on the original input keywords than to expansion-only matches. Preferred agent workflow: call the tool in compact mode first, then expand the cached result by query_id in full mode only if you need richer metadata; enable diagnostics only for debugging or tuning. Use it to narrow a large repo before deeper inspection. It returns structured output with summary counts, ranked files, snippets, and usage guidance. Pass an absolute directory path for reliable agent behavior. Relative directory values such as '.' only work when the MCP client exposes roots, so they are not portable across clients. The result is bounded and does not necessarily include every file that could be relevant for context. Only do further searches across the repository if this context is insufficient.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subpath | No | ||
| keywords | No | ||
| query_id | No | ||
| directory | No | ||
| max_files | No | ||
| match_mode | No | substring | |
| lines_after | No | ||
| output_mode | No | compact | |
| lines_before | No | ||
| max_snippets | No | ||
| max_total_lines | No | ||
| paths_exclude_glob | No | ||
| paths_include_glob | No | ||
| include_diagnostics | No | ||
| prefer_source_files | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||