Skip to main content
Glama

Get Code Context for a Symbol

get_context
Read-onlyIdempotent

Retrieves a token-budgeted AI-Builder-Markdown slice of one C# symbol's source plus its depth-1 neighborhood, so agents get focused context instead of the whole solution.

Instructions

Return a dense, token-budgeted AI-Builder-Markdown slice of the code around a symbol: the symbol's source plus its expanded neighborhood (direct dependencies + callees, depth 1). Pass a type or method simple name (use find_symbol first to disambiguate). budget caps the slice in tokens (floored at 8000; omitted, a default ceiling applies); the session notes an answer can lead with (agent wiring, config setup) come on top. The fastest single-symbol retrieval - prefer it over export_markdown (which renders the WHOLE solution) when you only need one symbol's context. Multi-TFM solutions are deduplicated to one declaration per type, the NEWEST TFM's where it has one (as find_symbol lists them; export_markdown keeps the unfiltered per-TFM render). Need a CHOSEN environment of one symbol (callers / tests / implementations / quality)? use explain_symbol. Bundling a whole task from a natural-language goal? use pack_for_task (read) or prepare_task (edit-ready: + covering tests & siblings).

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": {
      "sessionId": "<sessionId>",
      "symbol": "<symbol>"
    },
    "name": "get_context"
  }
}

Input Schema

NameRequiredDescriptionDefault
leanNoLean slice (default TRUE): drop the repeated <AI_CONTEXT_SPEC> format-rules preamble and the <AI_CONTEXT_META> block, and omit any enabled-but-empty graph section (the ones that would otherwise render just '- none'). On a focused single-symbol slice that boilerplate is >4x the actual signal. The PATH_LEGEND, COMPRESSION_LEGEND (decoding keys) and all non-empty sections are kept. Set false to get the full AI-Builder-MD document with the format contract.
budgetNoOptional token budget (floored at 8000). Caps the slice TWO ways: it compacts/drops method bodies AND - when the expanded neighborhood still overflows - drops the least-relevant non-seed types entirely, ranked by closeness to the seed and in-slice fan-in. The seed itself is never dropped: it renders with its full source when that fits the budget, otherwise as STRUCTURE (identity, members, every method signature) with a leading note naming the measured size of the full-code render and the budget that holds it. A leading comment discloses how many types were dropped. Omitted, the slice still renders against a ceiling (the active MCP profile's token budget, else a ~10000-token default budget) that bounds the neighborhood; pass a value for a tighter slice.
symbolYesThe type or method simple name to center the slice on. A qualified type name ('Ns.Type', 'Outer.Inner') reads as the type where every type of that simple name is one it names and no method shares it (a leading comment says so).
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeQualityMetricsNoWhen true, also emit the <QUALITY_HOTSPOTS> section plus complexity=""/ce="" tag attributes for the sliced symbols (cyclomatic complexity, efferent coupling). Default false (leaner slice). Set true when reviewing code quality / picking refactor targets.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.46521
    • changedInput schema / properties / symbol / description
      Previous value: -"The type or method simple name to center the slice on."New value: +"The type or method simple name to center the slice on. A qualified type name ('Ns.Type', 'Outer.Inner') reads as the type where every type of that simple name is one it names and no method shares it (a leading comment says so)."
  2. Changed1 schema field changedv0.5.46513
    • changedInput schema / properties / sessionId / description
      Previous value: -"The session_id returned by analyze_solution."New value: +"The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use."
  3. First observed

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive/closed-world, so the safety profile is covered; on top of that the description adds genuinely non-obvious behavior: budget compacts bodies then drops least-relevant non-seed types, the seed is never dropped and degrades to STRUCTURE with a size note, and dropped types are disclosed in a leading comment. Multi-TFM dedup to the newest TFM is also disclosed rather than left implicit. It stops short of describing pagination/ordering of the emitted sections, keeping it at 4 rather than 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose, budget mechanics, and sibling routing, with zero filler sentences — every clause carries routing or behavioral information. It is dense and long, and the parenthetical aside about the unfiltered per-TFM export_markdown render is more detail than most callers need, which keeps it from a 5.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter read tool with no output schema, the description carries the necessary burden: it characterizes the return artifact (dense AI-Builder-Markdown with sections, legend keys, leading disclosure comment) and how budget/lean alter it. An agent knows what it will get back and under what degradation, which is exactly what a missing output schema would otherwise leave unknown.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description earns an increment by adding semantics the schema does not fully carry, notably that session notes render on top of the budget and why the floor of 8000 exists relative to the default ceiling. Most parameter detail (lean, budget, qualified names) duplicates the schema, so it is not a full 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ("Return a dense, token-budgeted AI-Builder-Markdown slice of the code around a symbol") and immediately scopes it: the symbol's source plus expanded neighborhood at depth 1. It explicitly distinguishes itself from export_markdown (whole solution), explain_symbol (chosen environment), and pack_for_task/prepare_task (task bundling), so an agent can route without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives positive guidance ("the fastest single-symbol retrieval"), named alternatives with the condition that selects them, and prerequisite ordering ("use find_symbol first to disambiguate"). The when-not conditions are explicit, e.g. use export_markdown only when the whole solution is needed, use explain_symbol for callers/tests/implementations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.