search_content
Search full C/C++ file content for file-scope patterns like extern "C", #define, or type declarations, with FTS5 and ifdef filtering. Returns file-level matches with highlighted snippets.
Instructions
Find patterns in FULL file content — not limited to function bodies.
Searches ifdef-filtered file text — only code that actually compiles
for the current build configuration. Inactive #ifdef branches are
replaced with blank lines (preserving original line numbers).
Covers file-scope constructs that search_bodies cannot see:
extern "C", type declarations in headers, #include, #define,
global variables, namespace blocks. Also covers function bodies, but
search_bodies is preferred for body-level patterns (per-function
context, snippet highlights per match).
When to use search_content vs search_bodies vs search_code:
search_content— patterns anywhere in FILES (file scope + bodies):extern "C",InterruptIn,#define, type declarations.search_bodies— patterns in function BODIES only:.attach(,NVIC_SetVector(,callback(&.search_code— find symbols by NAME:interrupt handler,modem init.
project_only=True filters to application paths (src/, lib/). Default False includes vendor SDK files.
Results are file-level (one entry per matching file) — use
search_bodies for per-function granularity.
When files_fts is missing (legacy index), falls back to LIKE
search on files.content — results include _fallback: "like"
and no snippet highlighting. Run fw-context index to upgrade.
Read-only. No side effects. Requires the FTS5 index with file content.
Args:
query: FTS5 search terms. 1-3 words. Bare multi-word queries are
OR-joined (prefix-wildcarded). Prefer single-word queries.
E.g. 'InterruptIn', 'extern C', '#define'.
project_root: Project root. Auto-detected if omitted.
limit: Maximum results (default 20, max 100).
project_only: When True, exclude vendor SDK directories.
Returns: list of dicts, each with: file, language, mtime, _match_snippet (highlighted excerpt around the match).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum results (default 20, max 100). | |
| query | Yes | FTS5 search terms for full file content. 1-3 words. E.g. 'InterruptIn', 'extern C'. Bare multi-word = OR-joined. | |
| project_only | No | Exclude vendor SDK code (mbed-os/, .pio/, zephyr/, build/). When True, only your application code (src/, lib/). Default False. | |
| project_root | No | Project root. Auto-detected if omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |