Skip to main content
Glama

search_code

Find C/C++ symbols (functions, classes, enums) by name using full-text search, with optional kind filters and automatic query broadening for better results.

Instructions

Find C/C++ symbols by name — searches function/class/enum NAMES.

Searches symbol names, qualified names, signatures, docstrings, and pre-computed name tokens (CamelCase/snake_case split). Does NOT search function bodies — for patterns in code like .attach(, interrupt handler registrations, callback attachments use search_bodies instead.

Use when you know the concept but not the exact name ("interrupt handler", "modem init"). Prefer lookup_symbol when you already know the exact or prefix name.

Results include names, file locations, signatures, and docstrings — the metadata about each symbol, not the symbol's implementation code.

FTS5 syntax:

  • init* matches init, init_uart, initialize (trailing wildcard)

  • "spi init" matches the exact phrase "spi init"

  • Do NOT use underscore in queries — modem_init is split into modem AND init. Write modem init instead.

Progressive relaxation: when the initial FTS5 search returns nothing, the tool automatically broadens the search in up to six steps:

  1. FTS5 with kind filter — the original query with the user-provided kind constraint.

  2. FTS5 without kind filter — drops the kind constraint (users often guess the wrong kind for a symbol).

  3. name_tokens substring match — searches the pre-computed CamelCase/ snake_case token column (e.g. BuildType is indexed as "build type"). Requires at least N‑1 of N query terms to match.

  4. Single-term docstring LIKE — when only one query term was given and the token-based steps found nothing, does a raw LIKE over the docstring column to catch terms the FTS5 tokeniser may have missed.

  5. Individual term FTS5 — searches each query word separately and merges the results.

  6. Macro FTS5 fallback — searches the macros_fts table for matching #define names and values (kind="macro", _fallback="macros_fts").

Results from fallback steps carry _fallback indicating which method succeeded ("fts5", "name_tokens_like", "docstring_like", "individual_terms", "macros_fts").

Kind filter values: function, method, constructor, destructor, class, struct, union, enum, enum_constant, typedef, varglobal, varlocal, variable, field, namespace.

Each result may include summary, inputs, outputs when LLM analysis has been generated (fw-context index --analyze). These provide structured descriptions: what the symbol does, what parameters/data it receives, and what it returns/produces.

Read-only. No side effects.

Args: query: FTS5 search terms. Keep queries short — 1–3 words. project_root: Project root directory. Auto-detected from CWD if omitted. kind: Optional filter to return only symbols of this kind. limit: Maximum results (default 20, max 100). project_only: When True, exclude vendor SDK directories and return only application code. Default False.

Returns: list of dicts, each with: name, qualified_name, kind, file, line, is_definition, signature, docstring, is_template, is_virtual, is_pure_virtual. Enum constants include enum_value with the integer value. May also include template_usr, parent_usr, summary, inputs, outputs when available. Fallback results include _fallback with the method name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindNoOptional kind filter: function, method, constructor, destructor, class, struct, union, enum, enum_constant, typedef, varglobal, varlocal, variable, field, namespace.
imageNoSysbuild image name within the variant (multi-project). Omit for all images of the variant.
limitNoMaximum results (default 20, max 100).
queryYesFTS5 search terms. 1-3 words, omit underscores. E.g. 'modem init' not 'modem_init'. Supports trailing wildcard 'modem*'.
variantNoBuild variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants.
project_onlyNoExclude vendor SDK code. When True, only application code. Default False.
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?

With no annotations provided, the description carries the full burden and delivers thoroughly. It details the progressive relaxation algorithm (six numbered fallback steps), states expected result contents (metadata not implementation code), clarifies FTS5 tokenization quirks (underscore splitting), and explicitly declares 'Read-only. No side effects.' This is far beyond a minimal disclosure.

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, usage, FTS5 syntax, progressive relaxation, kind values, args, returns). Every section serves a distinct need, and the information density is appropriate for a tool with this complexity. It front-loads the primary purpose and the critical exclusion of function-body search.

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 description fully covers the tool's complexity: search scope, syntax, fallback steps, result fields, and parameter semantics. It also aligns with the output schema by enumerating returned fields and explaining optional enrichment. There are no significant gaps that would prevent an agent from using the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although schema coverage is 100%, the description adds rich semantics beyond the schema. For query, it explains FTS5 wildcard syntax, phrase matching, and underscore handling with concrete examples. It also explains behavioral impact of kind (dropped in fallback), project_only (excludes vendor SDK), and limit (default/max). This is substantial added meaning.

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+resource: 'Find C/C++ symbols by name — searches function/class/enum NAMES.' It clearly distinguishes itself from siblings by stating what it does NOT search (function bodies) and explicitly pointing to search_bodies for that, and by contrasting with lookup_symbol for exact-name lookups. This gives a sharp, scoped purpose.

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?

Usage guidance is explicit: 'Use when you know the concept but not the exact name' and 'Prefer lookup_symbol when you already know the exact or prefix name.' It also directs pattern-in-code searches to search_bodies. This covers when-to-use and when-not-to-use with named alternatives.

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