get_context
The workhorse tool. Compact, batched context for any set of files, modules, or symbols: docs, ownership, freshness, and optional source/callers/callees/metrics/community in one call.
If your agent only learns one tool, make it this one. get_context
absorbs what would otherwise be five or six separate calls (file
docs, symbol signatures, ownership, last-change history, source
bodies, callers and callees, centrality metrics, community membership,
and freshness) into a single call with a configurable include list.
Pass multiple targets at once.
When to call
- After
get_answerto verify or expand on cited files. - Before editing any file: check ownership, dependents, freshness, and governing decisions.
- Architectural questions: pair with
include=["metrics", "community"]to see centrality and cluster membership. - Always batch: one call with five targets is far cheaper than five calls with one target each.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
targetsrequired | string[] | — | File paths, module paths, or qualified symbol IDs (e.g. "src/auth/service.py::verify_token"). Pass as many as you need. |
include | string[] | ["docs", "freshness"] | Blocks to include. Default is ["docs", "freshness"]. Options: "docs", "full_doc", "ownership", "last_change", "source", "callers", "callees", "metrics", "community", "decisions", "skeleton" (file targets only). |
compact | boolean | true | True returns signatures only (lighter). False adds the structure block, docstrings, and imported_by. |
repo | string | — | Repository alias. Usually omitted. |
Returns
The response is a targets map keyed by the target string. Each entry contains:
| Block | What it gives you |
|---|---|
docs | Wiki title, summary, and symbols list (name, kind, signature, line, docstring). Adds structure block and imported_by for files; child file pages for modules; qualified_name, used_by, candidate matches for symbols |
full_doc | Same as docs but with the full page content_md |
ownership | primary_owner, owner_pct, contributor_count, bus_factor, plus recent_owner if the active maintainer differs from the historical primary |
last_change | ISO date, author, days ago |
source | Body, start_line, end_line, language, truncated flag (capped at 400 lines) |
callers / callees | Up to 20 each, filtered to confidence ≥ 0.7. Each entry: symbol_id, name, kind, file, confidence, edge_type |
metrics | pagerank, pagerank_percentile, betweenness, betweenness_percentile, in_degree, out_degree, community_id |
community | id, label, cohesion, top_members, neighbors with cross-edge counts |
freshness | confidence_score, freshness_status, is_stale |
decisions | Governing architectural decision records (if any) |
skeleton | (file targets) The file with bodies elided: every signature, the import preamble, and the bodies of only the most central symbols (ranked by symbol PageRank / hotspot / query match), token-budgeted. Typically ~15% of the full file's tokens. Elision markers carry 1-indexed line ranges so anything can be range-read back |
Top-level fields:
truncated:trueif output was capped at the token budget.dropped_targets,dropped_symbols: what got evicted when the budget was exceeded._meta.omitted: when anything was dropped, the refs to get it back:{ refs, tokens, restore }. Resolve withrepowise expand <ref>from a shell orget_symbol("repowise#<ref>")from any MCP client; truncation is no longer silent.
Example
get_context(["src/auth/service.py"])
get_context(
["src/auth/service.py::verify_token"],
include=["source", "callers"],
)
get_context(
["src/auth/", "src/payments/"],
include=["ownership", "metrics", "community"],
)
# Structure-level view of a large file at ~15% of the tokens
get_context(["src/big_module.py"], include=["skeleton"])Things worth knowing
- Token budget enforcement: ~8000 tokens (~32k chars) global cap. Truncation happens in stages: (1) strip heavy doc fields, (2) shrink symbol lists keeping query-matched symbols first, (3) drop whole targets. Largest targets are evicted first.
- Symbol prioritisation: within a target, symbols are ranked by exact name match → substring match → kind (class > function > method) → centrality. Navigationally important symbols survive truncation.
- Target resolution order: file_page → module_page → symbol
(exact then fuzzy) → file by
target_path. If none match, returns fuzzy path suggestions. freshnessis included by default: critical for the agent to detect stale indices.ownershipandlast_changeadd 200 to 500 bytes each; omit them on multi-turn sessions to save the cache.- Cross-repo enrichment (workspace mode): appends co-change partners and contract links (HTTP routes, gRPC services, topics) from other repos for files in a multi-repo workspace.
Pattern that works well: call get_answer first, then
get_context(targets=fallback_targets, include=["ownership", "last_change"])
on whatever the answer cited. Two calls, complete picture.
get_answer
One-call RAG synthesis over the wiki: it retrieves, gates on confidence, and returns a cited 2-5 sentence answer with fallback file targets. The first tool to call on any code question.
get_symbol
Raw source bytes for one indexed symbol with exact line bounds, cheaper and safer than reading the whole file and counting offsets. The only MCP tool that returns actual source code.