Skip to main content
Glama

search_bodies

Find code patterns inside function bodies (e.g., .attach, callback) to locate implementation logic, filtering out vendor code for app-only results.

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.
imageNoSysbuild image name within the variant (multi-project). Omit for all images of the variant.
limitNoMaximum results (default 20, max 100).
queryYesFTS5 search terms for function bodies. 1-3 words. E.g. 'attach', 'callback', 'rise'.
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 full burden and meets it thoroughly. It discloses that the tool is 'Read-only. No side effects. Requires the FTS5 index,' explains exact limitations (e.g., does not search file-scope constructs), describes result ordering (project code before vendor code), and notes that source is truncated at 2000 chars. This goes beyond typical descriptions.

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?

Although long, the description is exceptionally well-structured with bold headings, bullet lists, and clear section separation. Every sentence adds useful information—no fluff or redundancy. The structure makes the length acceptable and easy to scan, front-loading the core purpose before diving into details.

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 (7 parameters, output schema, various edge cases), the description is remarkably complete. It explains when to use the tool vs siblings, lists precise limitations, describes the return value structure (_match_snippet, source truncation), and even covers multi-project variant nuances. The output schema exists, yet the description still adds helpful context about result contents and ordering.

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?

The input schema covers all parameters with descriptions, but the description adds substantial semantic value beyond the schema. For example, it explains FTS5 query behavior ('Bare multi-word queries are OR-joined... Prefer single-word queries... wrap in double quotes') and provides nuanced guidance for project_only ('Set it True when the question is about YOUR code... Leave it False when vendor code is also relevant'), which the schema does not convey.

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 specific purpose: 'Find patterns in C/C++ function BODIES — the implementation code inside { }.' It explicitly distinguishes from siblings by contrasting 'search_bodies' vs 'search_code' and 'search_content,' making the resource and scope unambiguous.

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?

Extensive usage guidance is provided, including a dedicated 'When to use search_bodies vs search_code' section with concrete examples, a 'LIMITATION' section telling users to use search_content for file-scope patterns, and clear instructions on when to set project_only=True vs False. This covers when, when-not, and 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