Skip to main content
Glama

find_variables

Find C/C++ variables by name or prefix and identify every function that reads or writes them, tracing shared state and side effects across the call graph.

Instructions

Find C/C++ variables by name or prefix and trace who reads or writes them through the call graph. libclang-powered: splits variables into global (varglobal — file/namespace/class-scope) and local (varlocal — inside a function body).

Each result includes a type signature (bool timeSet, const IPAddress modbus_ip), the enclosing function for locals ("<file scope>" for globals), and a references list showing every function that reads or writes the variable — the same ref_kind values as find_references ("call", "ref", "member").

Use when you need to understand shared state, find who modifies a global variable, trace side effects, or distinguish important globals from loop counters. For general symbol search use search_code or lookup_symbol. For all references to a specific variable (including reads in expressions), use find_references.

Legacy indexes with kind="variable" (pre-split) are detected and included in results — reindex to fully benefit from the split.

Read-only. No side effects.

Args: name: Variable name or prefix to search. Uses LIKE match (e.g. g_ finds g_debug_level, g_state). project_root: Project root directory. Auto-detected if omitted. kind: Optional kind filter — "varglobal", "varlocal", "field", or None (all). Default None. limit: Maximum results (default 20, max 100).

Returns: list of dicts, each with: name (str), qualified_name (str), kind (str — "varglobal" or "varlocal"), file (str), line (int), signature (str — e.g. "const IPAddress modbus_ip"), enclosing_function (str — function name for varlocal, "<file scope>" for varglobal), enclosing_class (str — class name for static members, empty otherwise), references (list[dict] — function, file, line, ref_kind).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindNoFilter by kind: 'varglobal', 'varlocal', 'field', or None for all.
nameYesVariable name or prefix to search. Uses LIKE match (e.g. 'g_' finds g_debug_level, g_state).
limitNoMaximum results (default 20, max 100).
project_rootNoProject root. Auto-detected if omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

No annotations provided, so the description carries the full burden. It discloses read-only status, the libclang-based splitting, legacy index detection, and the exact structure of results including the references list with ref_kind values. This provides clear behavioral expectations.

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

Conciseness5/5

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

The description is long but well-structured with clear sections: purpose, result details, usage guidance, legacy note, read-only, args, returns. Each part adds value, and it uses formatting for readability. No filler.

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?

Given the tool has 4 params, an output schema, and is complex, the description is complete: it explains behavior, parameters, return values, and edge cases (legacy indexes), making it standalone.

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 coverage is 100%, and parameter descriptions are already detailed in the schema. The description's Args section largely duplicates information, adding no new meaning beyond what the schema provides. Thus baseline 3 applies.

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 C/C++ variables by name or prefix and trace who reads or writes them through the call graph.' It immediately distinguishes from siblings like search_code and find_references by mentioning the split into varglobal/varlocal and the references list.

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?

Explicitly states when to use: 'Use when you need to understand shared state, find who modifies a global variable, trace side effects, or distinguish important globals from loop counters.' It also names alternatives: 'For general symbol search use search_code or lookup_symbol. For all references to a specific variable... use find_references.'

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/turbyho/fw-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server