Skip to main content
Glama

search_bodies

Search function bodies in C/C++ code to find patterns like function calls and callback registrations. Returns highlighted excerpts from implementation code inside { }.

Instructions

Find patterns in C/C++ function BODIES — the implementation code inside { }.

Searches ONLY the text between { and } of function/method definitions. Does NOT search file-scope constructs (see Limitations below).

When to use search_bodies vs search_code:

  • search_bodies — patterns in function BODIES (what the code DOES): function call patterns (.attach(, .rise(, .fall(, callback(&), ISR registration code.

  • search_code — find symbols by NAME (what the code IS): modem init, interrupt handler, uart send.

Limitations — what search_bodies CANNOT find:

Only function/method definition bodies are indexed (is_definition=1 symbols with source text). The following are at FILE SCOPE and are NEVER in the source column:

  • extern "C" — linkage specifier at file scope

  • Type declarations in headers — InterruptIn _pin; in class bodies

  • #include, #define, #ifdef — preprocessor directives

  • Global/static variable definitions outside functions

  • Namespace declarations

  • Any code outside { } of a function definition

LIMITATION — search_bodies ONLY searches function bodies ({ }): If your pattern might be at file scope (class member declarations like InterruptIn _pin, function declarations, #define, extern "C", global variables), use search_content instead. search_bodies returns empty for any pattern outside function bodies.

For these patterns, use search_content which indexes full file content (not limited to function bodies).

When to set project_only=True: Your project contains two kinds of code:

  • Application code — code your team wrote.

  • Vendor SDK — framework/OS code shipped by a vendor, NOT written by your team.

Set project_only=True when the question is about YOUR code ("where do we register interrupt handlers?", "which functions call .attach()?"). Leave it False (default) when the vendor code is also relevant.

Results include _match_snippet — a highlighted excerpt showing each match in context (e.g. _timeout.<b>attach</b>(callback(...))). Project code sorts before vendor code in the output.

Read-only. No side effects. Requires the FTS5 index.

Args: query: FTS5 search terms. 1-3 words. Bare multi-word queries are OR-joined (each term prefixed with *). Prefer single-word queries for broad matching: 'attach' finds .attach(...) patterns including callback attachments, timer registrations, etc. For exact phrases wrap in double quotes: '"attach callback"'. project_root: Project root. Auto-detected 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, _match_snippet (excerpt around match), source (function body, truncated at 2000 chars).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindNoOptional kind filter: function, method, class, etc.
limitNoMaximum results (default 20, max 100).
queryYesFTS5 search terms for function bodies. 1-3 words. E.g. 'attach', 'callback', 'rise'.
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?

Despite no annotations, the description fully discloses behavior: read-only, no side effects, requires FTS5 index, limitations on what cannot be found (file scope), and return format including _match_snippet and sorting. Contradictions: none.

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 with headings, bullet points, and examples. It is front-loaded with purpose and usage guidelines. Every sentence adds value, though some repetition could be trimmed.

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's complexity (FTS5, multiple constraints) and the presence of an output schema, the description covers all necessary aspects: search domain, limitations, parameter details, return format, and usage context. Nothing critical is missing.

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%, baseline 3. Description adds significant value by explaining query syntax (OR-joined, exact phrases), auto-detection of project_root, default limit, and when to use project_only. Slightly above baseline due to concrete usage examples.

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 explicitly states the tool searches function bodies for patterns, distinguishing it from sibling tools like search_code and search_content. The verb 'find' and resource 'C/C++ function BODIES' are clear and specific.

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?

Dedicated sections cover when to use search_bodies vs search_code and search_content, with concrete examples. Also explains when to set project_only=True, providing clear decision criteria for the agent.

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