Skip to main content
Glama

lookup_symbol

Find C/C++ symbols by exact name or prefix using libclang indexing. Resolves build-conditional code, templates, and macros. Use when you know the symbol name; search_code for concepts.

Instructions

Look up a C/C++ symbol by name via libclang index — exact or prefix matching. Finds symbols text-based search can miss: build-conditional code, template instantiations, macro-expanded names. Macros are extracted via clang -dM -E during indexing so #ifdef-conditional macros resolve correctly for the active build config. Prefer this over search_code when you know the exact symbol name or a prefix (uart_ finds all UART symbols). Use search_code for keyword/concept search.

Read-only: yes. May auto-reindex stale files (non-blocking).

Args: name: Symbol name (exact match) or prefix (set exact=False). E.g. 'uart_init' finds the exact function; 'uart_' finds all symbols starting with 'uart_'. project_root: Project directory. Auto-detected if omitted. exact: True = exact name match, False = prefix LIKE match (default). limit: Maximum results (default 50).

Returns: list[dict]: Symbols with name, qualified_name, kind, file, line, signature, docstring, is_definition, is_template, is_virtual, is_pure_virtual fields. Enum constants include enum_value with the integer value. Macro results include kind="macro", value (raw definition), and expanded_value (preprocessor- resolved value). May also include template_usr, parent_usr, summary, inputs, outputs when available. When no results found, may include _did_you_mean with suggested symbol names. Empty list if not found.

**Note:** C++ constructors share their name with the enclosing
class, so ``lookup_symbol("Foo")`` may return both ``class Foo``
and ``constructor Foo::Foo()``.  Use the ``kind`` field to
filter when you need a specific symbol type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesSymbol name. Exact match if exact=True, prefix LIKE match otherwise. E.g. 'uart_init' or 'uart_'.
exactNoTrue = exact name match, False = prefix LIKE match (default).
imageNoSysbuild image name within the variant (multi-project). Omit for all images of the variant.
limitNoMaximum results returned (capped at 100, default 50).
variantNoBuild variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants.
project_rootNoProject root directory. Auto-detected from CWD if omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
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 of behavioral disclosure. It explicitly states 'Read-only: yes' and mentions a side effect: 'May auto-reindex stale files (non-blocking).' It also discloses important behavioral subtleties like constructor name sharing and macro extraction via 'clang -dM -E', which are critical for predicting tool behavior.

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 detailed but every sentence serves a purpose: purpose, usage comparison, safety note, parameter list, return format, and edge-case warning. It is well-structured with clear sections (Args, Returns, Note) and front-loaded with the core purpose and usage guidance, making it scannable despite its 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?

The tool has 6 parameters and no annotations, and the description thoroughly covers all aspects: parameter semantics, return value shape (including enum_value, macro fields, and '_did_you_mean'), side effects (auto-reindex), and edge cases (constructors). It is fully self-contained for an agent to select and invoke correctly.

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 baseline is 3. The description adds meaningful value beyond the schema by giving concrete examples for name ('uart_init' vs 'uart_'), explaining the exact/prefix semantics, and highlighting the constructor name-sharing caveat. This goes beyond the schema's field descriptions and aids correct parameter usage.

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 clearly states the tool looks up C/C++ symbols by name via libclang with exact or prefix matching. It explicitly distinguishes itself from search_code by noting it finds symbols text-based search misses, and provides a clear directive: 'Prefer this over search_code when you know the exact symbol name or a prefix.'

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?

Provides explicit when-to-use guidance with an alternative: 'Prefer this over search_code when you know the exact symbol name or a prefix... Use search_code for keyword/concept search.' Also explains the prefix behavior with an example ('uart_' finds all UART symbols), making usage conditions clear.

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