Skip to main content
Glama

get_symbol_context

Retrieve a C/C++ symbol's body, signature, callers, and callees in one response to understand what it does and how it fits into the codebase.

Instructions

Rich one-shot context for a C/C++ symbol: body, signature, the direct callers and callees. Answers "what does this do and how does it fit in the system?" in a single response — libclang powers the call graph, not regex. Falls back to macro display when the symbol is not found.

Prefer this over get_source when you also need callers, callees, indirect call sites, or LLM analysis — all returned in a single call. If you only need the raw function body (no metadata), get_source is slightly faster. For transitive call-graph exploration use find_all_callers_recursive or find_callees_recursive.

The callers and callees include vendor/SDK code — the call graph naturally spans project and vendor boundaries in both directions (project → vendor API, vendor callback → project handler). Each list is cut (callers at 50, callees at 100), and its *_total says how many there are; *_hint names the tool that pages a cut list.

The body is ifdef-filtered, the same as in get_source: a line of an inactive #if branch comes back blank and the line numbers do not move. source_origin says whether the text is the filtered copy ("index") or the file itself ("disk", every branch present).

Read-only. No side effects.

Args: name: Symbol name. Returns body, signature, the direct callers and callees (each list with its total). project_root: Project root. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name.

Returns: dict with: name, qualified_name, kind, file, line, signature, docstring (raw Doxygen comment text), is_definition, callers (list, max 50 — call, indirect and implicit_construct references, each with its line, its column, its origins and entry as in find_callers), callees (list, max 100 — one row for each callee and kind of reference), source (body text), indirect_call_sites (list, max 200, the rows of find_indirect_call_sites — for a field/variable symbol, the calls through the function pointer; for a function, method or lambda, the indirect calls that it makes). For a field or a variable also indirect_targets (list, max 50, the rows of find_indirect_targets: each function it can hold, and where the code stored it), and slot_escapes (True) when code out of view can write it: a call through it then also reaches each function of its type. callers_total, callees_total, indirect_call_sites_total and indirect_targets_total count each whole list. When a list is cut, callers_hint, callees_hint, indirect_call_sites_hint or indirect_targets_hint names the tool that pages it. For an enum also returns constants (at most 200), constants_total and, when the list is cut, constants_hint; for an enum constant, enum_value. For macros returns kind="macro", signature (#define NAME or #define NAME(a, b)), is_function_like, value (the replacement text ALONE) and expanded_value or expanded_values (the value in the build, see lookup_symbol). When LLM analysis has been generated (fw-context index --analyze), includes llm_analysis: {summary, inputs, outputs, model, analyzed_at} with a structured description of the symbol's purpose, parameters, and return values/side effects.

When the file changed after the last index run, the dict adds
``stale`` (True) and ``stale_warning`` (str), and ``source_origin``
tells where the body comes from: ``"disk"`` when the symbol did not
move, ``"index"`` when it did.  The callers and callees come from the
index in all cases, thus a stale dict can hold an incomplete list.
``_source_truncated`` (True) marks a body that a cap cut, as in
``get_source``.

The dict also carries the libclang flags of the symbol:
is_virtual, is_pure_virtual, is_template, parent_usr, and
template_usr.  For a virtual method it adds ``overrides`` (the base
methods that this method overrides) and ``overridden_by`` (the
derived methods that override it) — use these two before you change
a virtual method.

An ``ambiguous_warning`` key means that *name* matched more than one
symbol, such as two classes with a method of the same name.  Every
part of this answer — body, callers and callees — is about the ONE
symbol that the key names.  ``candidates`` (max 20) lists the others
and ``candidates_total`` counts them.  Give a ``qualified_name`` from
it to ask about one symbol only.

A symbol in a file outside the project root, such as an SDK header,
is returned and not refused.

On failure the dict holds only ``error`` with the reason.

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": {
      "name": "<name>"
    },
    "name": "get_symbol_context"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYesSymbol name. Returns body, signature, the direct callers and callees (each list with its total).
imageNoImage of the build: a separate program, such as the application or the bootloader. On a project of more than one build, give it when that build has an image name, as the refusal lists it.
projectNoProject name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both.
variantNoVariant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build for you. One query answers for ONE build.
project_rootNoProject root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.32.1
    • changedInput schema / properties / image / description
      Previous value: -"Sysbuild image within the variant. Required when the variant holds several: each image is a separate program."New value: +"Image of the build: a separate program, such as the application or the bootloader. On a project of more than one build, give it when that build has an image name, as the refusal lists it."
    • changedInput schema / properties / name / description
      Previous value: -"Symbol name. Returns body, signature, all direct callers and callees."New value: +"Symbol name. Returns body, signature, the direct callers and callees (each list with its total)."
    • changedInput schema / properties / variant / description
      Previous value: -"Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build."New value: +"Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build for you. One query answers for ONE build."
  2. Changed3 schema fields changedv0.32.0
    • changedInput schema / properties / image / description
      Previous value: -"Sysbuild image name within the variant (multi-project). Omit for all images of the variant."New value: +"Sysbuild image within the variant. Required when the variant holds several: each image is a separate program."
    • addedInput schema / properties / name / minLength
      Added value: +1
    • changedInput schema / properties / variant / description
      Previous value: -"Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants."New value: +"Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build."
  3. Changed3 schema fields changedv0.30.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / project
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both.",
      +  "title": "Project"
      +}
    • changedInput schema / properties / project_root / description
      Previous value: -"Project root. Auto-detected if omitted."New value: +"Project root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those."
  4. Changed2 schema fields changedv0.25.3
    • addedInput schema / properties / image
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Sysbuild image name within the variant (multi-project). Omit for all images of the variant.",
      +  "title": "Image"
      +}
    • addedInput schema / properties / variant
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants.",
      +  "title": "Variant"
      +}
  5. Changed1 schema field changedv0.24.0
    • removedInput schema / properties / project_only
      Removed value: -{
      -  "default": true,
      -  "description": "When True (default), filters callers and callees to project paths (excludes SDK/vendor).",
      -  "title": "Project Only",
      -  "type": "boolean"
      -}
  6. Changed1 schema field changedv0.5.0
    • addedInput schema / properties / project_only
      Added value: +{
      +  "default": true,
      +  "description": "When True (default), filters callers and callees to project paths (excludes SDK/vendor).",
      +  "title": "Project Only",
      +  "type": "boolean"
      +}
  7. Changed1 schema field changedv0.2.1
    • changedInput schema / properties / name / description
      Previous value: -"Symbol name. Returns body, signature, up to 5 callers and 5 callees in one call."New value: +"Symbol name. Returns body, signature, all direct callers and callees."
  8. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

No annotations are supplied, so the description carries the full burden, and it does. It discloses read-only/no-side-effects, that the body is ifdef-filtered with line numbers preserved, how source_origin, stale, and _source_truncated behave, the truncation caps (50/100/200/20) with *_total and *_hint companions, that vendor/SDK code is included, ambiguous-name handling with candidates, that out-of-root symbols are returned rather than refused, and the error-key failure shape. This capacity to describe caveats is far beyond name-and-args restatement.

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?

The purpose, the routing alternatives, and the caveats come before the long Returns block, which is the right order. Every block serves the tool, but the Returns section is very long and sometimes repetitive, for example the redundant explanation of variant/image selection and the doubled cut-list/hint phrasing. This costs one point, not many.

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?

There is no output schema, so the description must document what comes back, and it does thoroughly: per-kind return shapes for functions, fields, enums, and macros, including totals, hints, and LLM analysis. With five parameters, build-selection ambiguity, and fallback behaviors, an agent has what it needs to call the tool and read the result correctly.

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

Parameters3/5

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

The schema has 100% description coverage, so the baseline for this dimension is 3. The Args section largely restates the schema text for project, variant, image, and name, with no extra meaning. Only the name entry adds a little context by listing what a lookup returns.

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?

It names a specific verb and resource: rich one-shot context for a C/C++ symbol. It also lists exactly what comes back: body, signature, direct callers, and callees. It clearly distinguishes this tool from each sibling: get_source, find_all_callers_recursive, find_callees_recursive, find_callers, find_indirect_call_sites, and find_indirect_targets. It even justifies why libclang powers the implementation instead of regex.

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?

It states when to use this tool: when you need callers, callees, indirect call sites, or LLM analysis. It states when not to use it: when you need only the raw body, because get_source is slightly faster. It names alternatives for transitive exploration. It also gives tie-breaking rules for project vs. project_root and for variant/image: give one build, and fw-context does not select one.

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