Skip to main content
Glama

trace_data_flow

Trace how a C/C++ data type flows through call paths to a target function. Uses libclang to map cross-file data flow, revealing how structures reach their destination.

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 functions whose signature mentions type_name, then looks for call paths from those functions 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). timeout_ms: Maximum total execution time in milliseconds (default 30000). Clamped to 1000–300000. 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: list of dicts with a leading _summary entry: {_summary (str), _type (str), _target (str)}, followed by source entries each with: source_name, source_qualified_name, source_kind, source_file, source_line, caller_count, reachable (bool), and paths (list of call path dicts — empty when unreachable).

A source entry with ``timed_out: True`` means that the path search
stopped at the time limit for that source.  Its ``reachable: False``
thus means "not proved reachable", not "proved unreachable".

Never empty: one dict with ``info`` replaces an empty result.
Check that key first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageNoSysbuild image within the variant. Required when the variant holds several: each image is a separate program.
limitNoMaximum source functions to trace (default 15, max 15).
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.
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

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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."
  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.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"
      +}
  5. Addedv0.2.4

TDQS

A4.8/5.0
Behavior5/5

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

No annotations are provided, so the description carries the full burden. It states 'Read-only. No side effects. Requires the reference index', discloses timeout behavior ('timed_out: True means ... not proved reachable'), and warns about the never-empty result with an info dict. This is substantial behavioral disclosure beyond the schema.

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 organized: purpose, limitations, prerequisites, arguments, return semantics. It is front-loaded with the core purpose. Some redundancy exists because the Args section largely echoes the input schema, but the added examples and clarifications justify most of the length.

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 9-parameter tool with no annotations, the description is highly complete. It covers prerequisites, limitations, parameter disambiguation, timeout semantics, empty-result behavior, and return structure. An agent has enough context to call it correctly without external knowledge.

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 description coverage is 100%, so the baseline is 3. The description adds value with concrete examples for type_name and to_symbol, the 'Give one of the two, not both' guidance for project/project_root, and the timeout clamp 'Clamped to 1000–300000' which is not present in 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: 'Trace how C/C++ data of a given type flows to a target function via libclang call paths.' It distinguishes the tool from text-based search ('which text-based search cannot trace across translation units') and from sibling tools by naming the find_* family and find_call_path.

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?

The description gives explicit usage context: 'Works best for synchronous driver stacks' and 'Cannot follow async flows (message queues, interrupts, RS485 callbacks).' It also routes users to alternatives: 'For exact call-graph queries use the find_* family; verify specific paths with find_call_path.'

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