Skip to main content
Glama

trace_data_flow

Trace how a C/C++ data type flows to a target function by mapping call paths via libclang, revealing data movement across translation units.

Instructions

Trace how C/C++ data of a given type flows to a target function via libclang call paths. libclang-powered: finds functions by type signature and maps call paths through the full call graph, which text-based search cannot trace across translation units.

Finds definitions whose signature mentions type_name (substring match, any symbol kind, most-called first), then looks for call paths from those to to_symbol. Returns a data flow map — useful for understanding how a data structure travels through the system to its destination.

Works best for synchronous driver stacks (e.g. sensor read → I2C write). Cannot follow async flows (message queues, interrupts, RS485 callbacks). For exact call-graph queries use the find_* family; verify specific paths with find_call_path.

Read-only. No side effects. Requires the reference index (fw-context index — refs on by default).

Args: type_name: Type name to trace. E.g. 'SensorData' or 'Config::SensorData'. to_symbol: Target symbol name. E.g. 'uart_send' or 'UART_DRIVER::send'. 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. max_depth: Maximum call path depth (default 8, max 20). limit: Maximum source functions to trace (default 15, max 15). offset: Skip this many source functions. Reads the next page; the page notice names the offset to use. timeout_ms: Maximum total execution time in milliseconds (default 30000). Clamped to 1000–300000. The budget is for one page. 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: The page notice {total, offset, shown, more, hint} comes before the rows of the answer: total counts every source function that matches. Then a _summary entry for this page: {_summary (str), _type (str), _target (str)}, followed by source entries each with: source_name, source_qualified_name, source_kind, source_file (absolute), source_line, caller_count, reachable (bool), and paths (up to 3 path dicts as find_call_path gives them; the key is absent when unreachable). When to_symbol matches more than one symbol, a source entry also holds the warning that names them, and each path its target_qualified_name.

A source entry with ``timed_out: True`` means that the time budget
ran out before the search for that source began.  Its
``reachable: False`` thus means "not checked", not "proved
unreachable".  Such a source counts as shown, thus the hint goes
past it.  To check it, call again with the same ``offset``: each
page gets the whole time budget.

A source entry with ``budget_spent: True`` means that the path
search of that source spent its budget of node expansions.  Its
``reachable: False`` thus means "not found", not "proved
unreachable".

A page after the last source function gives one ``info`` dict
that names the total.  Never empty: one dict with ``error`` or
``info`` replaces an empty result.  Check both keys first.

Input Schema

NameRequiredDescriptionDefault
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.
limitNoMaximum source functions to trace (default 15, max 15).
offsetNoSkip this many source functions. Reads the next page.
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.
max_depthNoMaximum call path depth (default 8, max 20).
to_symbolYesTarget symbol name. E.g. 'uart_send' or 'UART_DRIVER::send'.
type_nameYesType name to trace. E.g. 'SensorData' or 'Config::SensorData'.
timeout_msNoMaximum total execution time in milliseconds (default 30000).
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

NameRequiredDescriptionDefault
resultYes

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."
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Skip this many source functions. Reads the next page.",
      +  "minimum": 0,
      +  "title": "Offset",
      +  "type": "integer"
      +}
    • 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. Changed9 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 source functions to trace (default 15)."New value: +"Maximum source functions to trace (default 15, max 15)."
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • changedInput schema / properties / max_depth / description
      Previous value: -"Maximum call path depth (default 8)."New value: +"Maximum call path depth (default 8, max 20)."
    • addedInput schema / properties / max_depth / minimum
      Added value: +1
    • addedInput schema / properties / timeout_ms / minimum
      Added value: +1
    • addedInput schema / properties / to_symbol / minLength
      Added value: +1
    • addedInput schema / properties / type_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.25.2
    • addedInput schema / properties / timeout_ms
      Added value: +{
      +  "default": 30000,
      +  "description": "Maximum total execution time in milliseconds (default 30000).",
      +  "title": "Timeout Ms",
      +  "type": "integer"
      +}
  6. Addedv0.2.4

TDQS

A4.7/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: it declares read-only/no side effects, requires the reference index (with the enabling command), states the async-flow limitation, and explains subtle partial-result semantics (timed_out means 'not checked', budget_spent means 'not found', not 'proved unreachable').

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

Conciseness3/5

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

Purpose, limitations, and alternatives are front-loaded, which is good, but the long Args and Returns blocks largely restate the input schema and output schema (both fully documented). Since an output schema exists, the two-paragraph explanation of page notice, _summary, source entries, and error/info dicts is largely 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?

For a complex 10-parameter call-graph tracer, the description covers use cases, hard limitations, index prerequisites, pagination, timeout budgeting, and ambiguous-result handling. An agent has everything needed to invoke it correctly, with return-value detail additionally backed by an output schema.

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 already 100%, so the baseline is 3, but the description adds real meaning beyond the schema: max_depth cap of 20, the 1000–300000 clamp on timeout_ms, the per-page nature of the timeout budget, and the offset pagination hint. The project/project_root 'give one, not both' rule mostly repeats 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?

States a precise verb+resource: tracing how C/C++ data of a given type flows to a target function via libclang call paths. It explicitly contrasts itself with text-based search and names the sibling family (find_* / find_call_path), so an agent can distinguish it without opening other 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 explicit positive cases ('works best for synchronous driver stacks, e.g. sensor read → I2C write') and exclusions ('cannot follow async flows: message queues, interrupts, RS485 callbacks'). It also routes to alternatives — find_* for exact call-graph queries and find_call_path to verify specific paths.

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