Skip to main content
Glama

find_callers

Find direct and indirect callers of a C/C++ function: function pointers, callbacks, ISR vectors, and struct initializers included. Returns immediate call sites with file, line, and caller.

Instructions

Find who calls a C/C++ function — direct calls AND indirect via function pointers, callbacks, interrupt vector registrations, and struct init lists. libclang-powered: detects function-pointer assignments and ISR vector registrations that text-based search cannot see.

Falls back to macro lookup when the symbol is not found as a function/method: returns the macro definition (kind="macro") and files that use it (ref_kind="macro_use").

Use when you need a quick, flat list of immediate callers. For the full transitive call tree (who calls this indirectly through other functions), use find_all_callers_recursive. For all references including reads and member accesses, use find_references. For a path between two specific symbols, use find_call_path.

Read-only. No side effects. Requires the reference index (fw-context index — refs are on by default). Only direct call sites are returned; callers more than one hop away are not included.

Indirect edges (ref_kind: "indirect") are detected when a function pointer references a function through:

  • Call arguments: callback(&Class::method, this), EventQueue::call_every(ms, obj, &handler)

  • Assignments: driver.onData = &handleData, global_cb = &handler

  • Variable initializers: static void (*fp)(int) = &handler

  • Struct/array init lists: {.on_data = &handler}, {&fn_a, &fn_b}

Args: name: Symbol name to find callers of. Uses the same three-tier resolution as find_references (exact name, exact qualified, suffix LIKE). project_root: Project root directory. 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. limit: Maximum results of one page (default 50, max 200). offset: Skip this many results. Reads the next page of a symbol with many call sites; the page notice names the offset to use. variant: Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build. image: Sysbuild image within the variant. Required when the variant holds several: each image is a separate program.

Returns: The page notice first — total, offset, shown, more — then a dict per call site with: file, line, ref_kind ("call", "indirect", "implicit_construct", or "macro_use"), caller (enclosing function name), caller_kind ("function", "method", …). Macro fallback puts a dict with kind="macro", signature (#define free: NAME or NAME(a, b)), is_function_like, value (the replacement text ALONE) and expanded_value between the notice and the rows; that answer pages too, and its total counts the uses in active code only — a use inside a comment is not one.

When *name* matches more than one symbol, such as two classes with
a method of the same name, the answer holds the call sites of all
of them.  A ``warning`` dict then comes first and names the
symbols, and each result carries ``target_qualified_name``.  Give
the full qualified name to ask about one symbol only.

A virtual method with no call site of its own answers with the
call sites of the methods that override the same base method.
Those rows reach a PEER and not the symbol you named, and the page
notice counts them, thus a ``warning`` dict always leads such an
answer and says so.  Read it before you report a caller count.

Never empty: one dict with ``error`` (symbol not resolved) or
``info`` (no references of this kind).  Check both keys first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesSymbol name to find callers of. Returns direct call sites and indirect calls via function pointers.
imageNoSysbuild image within the variant. Required when the variant holds several: each image is a separate program.
limitNoMaximum results of one page (default 50, max 200).
offsetNoSkip this many results. Reads the next page of a symbol with many call sites.
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.
variantNoBuild variant (multi-build project). Omit to use default_variant. 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.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 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."
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum results."New value: +"Maximum results of one page (default 50, max 200)."
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • addedInput schema / properties / name / minLength
      Added value: +1
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Skip this many results. Reads the next page of a symbol with many call sites.",
      +  "minimum": 0,
      +  "title": "Offset",
      +  "type": "integer"
      +}
    • 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."
  2. 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."
  3. 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"
      +}
  4. Changed1 schema field changedv0.2.1
    • changedInput schema / properties / name / description
      Previous value: -"Symbol name to find callers of. Returns direct call sites."New value: +"Symbol name to find callers of. Returns direct call sites and indirect calls via function pointers."
  5. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and does so thoroughly: read-only/no side effects, index requirement, macro fallback behavior, pagination format, ambiguity warnings, virtual-method override behavior, and the never-empty error/info contract are all disclosed. This goes far beyond the structured fields and gives the agent a reliable model of what happens.

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 description is long but well-structured with clear sections and bullet-like formatting. Nearly every sentence earns its place given the complexity of the tool, though some repetition of schema parameter details could be trimmed. Front-loading the core purpose and usage guidance is effective.

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?

Despite an output schema being present, the description adds a detailed Returns section covering pagination, macro results, ambiguity warnings, and virtual-method callers. It also documents the never-empty error/info contract. For a tool with this behavioral complexity and seven parameters, nothing essential is missing.

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 adds meaningful extra context beyond the schema: the three-tier name resolution, the pagination notice naming the offset, the project vs project_root relationship, and the multi-build variant/image distinctions. It does not merely repeat the schema.

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?

The description opens with a specific verb and resource ('Find who calls a C/C++ function') and immediately distinguishes direct vs. indirect calls, explicitly naming sibling tools for other needs. This lets an agent separate find_callers from find_references, find_call_path, and find_all_callers_recursive 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?

It gives explicit when-to-use guidance ('Use when you need a quick, flat list of immediate callers') and names the alternatives for transitive calls, all references, and path finding. It also states requirements such as the reference index and the one-hop limitation, leaving no ambiguity about when this tool is the right choice.

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