optimize_context_tool
Retrieve targeted source code matching a query, compressed to fit a token budget. Avoid reading full files to save tokens and get direct answers.
Instructions
Return the most relevant REAL source code for a question, within a token budget.
Use this FIRST for any "how does X work / where is Y" question about the
codebase, and prefer it over reading files or grepping. Call it ONCE per
question: the returned optimized_context contains the relevant code —
answer directly from it and do NOT separately read the files it came from
(that defeats the whole point of the token savings).
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": {
"codebase_path": "<codebase_path>",
"query": "<query>"
},
"name": "optimize_context_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| codebase_path | Yes | ||
| query | Yes | ||
| token_budget | No |