Skip to main content
Glama

search_bodies

Search function bodies in C/C++ source to find implementation patterns like .attach() or NVIC_SetVector(). Returns highlighted excerpts showing each match.

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): .attach(, NVIC_SetVector(, .rise(, .fall(, SerialBase::RxIrq, 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: src/, lib/ — code your team wrote.

  • Vendor SDK: mbed-os/, .pio/, zephyr/, build/ — 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 ("how does mbed's Ticker::attach work?").

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 Ticker::attach, Timeout::attach, 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 (mbed-os/, .pio/, zephyr/, build/) and return only application code (src/, lib/). 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', 'NVIC_SetVector', 'rise'.
project_onlyNoExclude vendor SDK code (mbed-os/, .pio/, zephyr/, build/). When True, only your application code (src/, lib/). 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, the description fully discloses behavioral traits: it is read-only, requires FTS5 index, searches only function bodies, does not search file-scope constructs, and returns _match_snippet. Limitations about what is not indexed are explicitly stated.

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 quite long but well-structured with headings, bullet points, and clear sections. It front-loads the main purpose and usage. Slightly verbose but organized, so earns a 4.

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 (5 params, output schema exists), the description is thorough. It covers all aspects: purpose, usage distinctions, limitations, argument details, output fields, and behavior. It is complete without requiring additional information.

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?

The input schema already describes all 5 parameters with 100% coverage. The description adds value by providing context: query syntax (bare words OR-joined, phrase wrapping), meaning of project_only, limit max, and kind filter. This enhances understanding beyond 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 clearly states the tool's function: searching patterns inside function bodies (implementation code within {}). It distinguishes itself from siblings like search_code and search_content by specifying what it searches (bodies) vs. what it does not (file-scope constructs, names, etc.). The purpose is specific, well-defined, and differentiated.

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 guidance on when to use search_bodies vs. search_code (patterns in bodies vs. symbols by name) and search_content (for file-scope patterns). Also explains when to set project_only=True for application vs. vendor code. Limitations are clearly enumerated, giving comprehensive usage instructions.

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