Search Codebase via Local Hybrid Lexical Index
search_codebaseLocate functions, classes, and architectural concepts in local repositories via offline hybrid keyword and semantic ranking of code snippets and file locations.
Instructions
Executes private local hybrid search combining BM25 keyword matching and TF-IDF semantic scoring across repository code, distinguishing from 'query_memory_store' and 'build_project_context' by indexing source code identifiers and docstrings rather than querying agent episodic memory or generating context trees.
Parameters:
query: Free-text search phrase, function name, class identifier, or concept description to search across the codebase.project_root: Directory path of the repository to index and search; defaults to current working directory.top_k: Maximum count of ranked results to return (integer between 1 and 20; defaults to 5).
Behavior:
Mutability: Strictly read-only; queries local files without altering code or persisting external indices on disk.
Idempotency: Deterministic; identical queries against the same codebase state produce identical rankings.
Privacy & Network: 100% offline local CPU execution; zero remote embedding APIs, cloud billing, or network egress.
Performance & Resources: Sub-millisecond query latency (<15ms) across 1,000 files with <35MB RAM footprint; thread-safe.
Auth: Zero authentication, API keys, or cloud credentials required.
Return Structure: Emits ranked Markdown list with file paths, matching line ranges, relevance scores, and code snippet extracts.
Error Handling: Returns clean empty-match notice with suggested query terms if no relevant tokens or symbols match.
Usage Guidelines:
When to use: Quickly locate functions, classes, definitions, or architectural concepts in a repository using natural language or symbol names at zero cost.
When NOT to use: Do not use for querying persistent agent semantic memory or causal decision graphs (use 'query_memory_store' instead); do not use for building full hierarchical context trees (use 'build_project_context' instead).
Returns: Ranked list of matching code snippets with file paths, line ranges, relevance scores, and matched symbol definitions.
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": {
"query": "<query>"
},
"name": "search_codebase"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term or natural language description of the code to locate. | |
| top_k | No | Maximum number of ranked results to return (default: 5). | |
| project_root | No | Root directory of the repository to search (default: current directory). | . |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |