Skip to main content
Glama

get_symbol_context

Retrieve a C/C++ symbol's body, signature, and direct callers/callees in one call to understand its role and system fit.

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 and indirect references, each with its line), callees (list, max 100 — one row for each callee and kind of reference), source (body text), indirect_call_sites (list, max 200 — for a field/variable symbol, where the function pointer is invoked; for a function/method, the calls through function pointers that it makes). callers_total, callees_total and indirect_call_sites_total count each whole list. When a list is cut, callers_hint, callees_hint or indirect_call_sites_hint names the tool that pages it. For field and variable symbols that have function pointer type, also includes resolution: {assignments_found, call_sites_found, resolved, note} indicating whether assignments and call sites are linked (Phase 3). resolved=False with a note when parts are missing — LLM can detect uncertainty. 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 (preprocessor-resolved). 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.

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?

With no annotations, the description carries the full burden and does so: 'Read-only. No side effects.', callers/callees span vendor/SDK boundaries, lists are cut at 50/100/200 with totals and paging hints, the body is ifdef-filtered with blanked lines and fixed line numbers, source_origin distinguishes index vs disk, stale-file behavior, and ambiguity via ambiguous_warning/candidates. This is unusually rich disclosure for a read tool.

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?

Purpose and routing to alternatives are front-loaded, and the Args:/Returns: structure is conventional. The Returns block is long, but with no output schema it is the only place return shapes can be documented; a few lines (e.g. the Args restatement of callers/callees totals) are redundant.

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?

No annotations and no output schema, so the description must cover both the safety profile and the return contract — and it does: every key, list cap, hint, stale/ambiguous case, and the failure mode ('the dict holds only error with the reason'). An agent has everything needed to call and interpret it.

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?

Schema description coverage is 100%, and the Args section largely restates the same text that already appears in the schema (project, project_root, variant, image). It does add the useful 'give one of the two, not both' framing and the note that fw-context does not auto-select a build, but that nuance is also present in the schema descriptions.

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?

Opens with a specific verb+resource: 'Rich one-shot context for a C/C++ symbol: body, signature, the direct callers and callees.' It explicitly differentiates from siblings by naming get_source and the recursive callers/callees tools as the alternatives it is not.

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?

Two explicit selection rules: prefer this over get_source when you also need callers/callees/analysis, use get_source if you only need the raw body, and use find_all_callers_recursive / find_callees_recursive for transitive exploration. It also names list_projects as the source of project ids and states the project vs project_root either/or.

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