fw-context-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
CRITICAL: C/C++ questions → fw-context ONLY. This is NOT optional.
For C/C++ code, use fw-context instead of ANY external search or file-reading tool.
SELF-CORRECT: the moment you reach for a tool that is NOT fw-context for C/C++ code, stop and use the fw-context equivalent instead.
EVERY ANSWER IS IFDEF-FILTERED. fw-context gives the code that COMPILES for the build of the query. A line of an inactive #if branch is blank in the content of read_file, in the text that search_content and search_bodies search, and in the body that get_source and get_symbol_context give. Line numbers never move. Thus a dead #ifdef block cannot reach you as live code. A comment and a preprocessor directive are part of the answer: a block comment keeps its closing marker, and an include guard shows. A blank line is thus an inactive line, or a line that is blank on disk, and nothing else. Three limits: • The filter needs an index. When a file changed after the last index run, get_source and get_symbol_context set a stale_warning. When the symbol did not move, they give the current text from the DISK, which holds every branch, and set source_origin: "disk". Read both before you cite such a body. • An empty result can mean the pattern is only in a dead branch. That is an answer, not a failure: the code does not compile. • A file can come back with every line blank. read_file marks it with all_lines_inactive and a warning. Such a file holds code, and that build compiles none of it — NOT an empty file.
AN INDEX THAT IS NOT CURRENT. When the index of the build of a query
is not current, the answer says so: a dict gets index_state and
index_warning, a list gets a leading row with warning and
index_state. The answer then comes from the last index run. Act
on index_state:
• "reindexing" or "pending" — an index run updates the index. WAIT:
repeat the call, or call get_project_status after about 30 s. Use
the old answer only when the user tells you to continue. Do not
start a second index run.
• "not_scheduled" — no index run updates the index. Tell the user
the command that the warning names. When it names none, call
get_project_status: it names the command.
• "failed" — the last index run failed, because the build is not
there or the run stopped. A dict also gets build_warning. Give
the text to the user: it names the command that repairs it.
No index_state: the quick checks of the query found no reason. They
can miss a changed header, a changed file that the answer does not
name, or a new source file when the answer is not empty.
get_project_status does the full check of each build.
TOOL SELECTION (pick the right one): • Symbol by exact/prefix name _____ → lookup_symbol (e.g. "uart_", "main") • Symbols by concept/topic _________ → search_code (e.g. "interrupt handler") • WHICH DEFINITION holds the code ___ → search_bodies (e.g. "attach", "SELF_TEST") • WHICH FILES a topic touches ______ → search_content (e.g. "extern C", "SELF_TEST") • Read a file, or a window of it ____ → read_file (line_numbers, start_line, end_line) • Read function body + callers/callees → get_symbol_context (preferred) / get_source • Function pointer calls/targets ____ → find_indirect_call_sites / find_indirect_targets • Interrupt handler of each vector __ → get_vector_table (ISRs have no caller) • Natural-language question ________ → smart_search (slow, thorough)
IMPORTANT: search_code searches symbol NAMES (what the code IS).
search_bodies searches the TEXT OF EVERY DEFINITION — not only
functions. It reaches function and method bodies, AND the body of a
class, struct, union, enum or namespace, AND a global with a multi-line
initializer. An enum constant, a bit field, a member declaration such
as InterruptIn _pin; are all inside search_bodies.
A match on a type answers with the type: a query for one enum constant
returns the enum, and match_lines gives the line of the constant.
Only the TEXT matches: a hit in the name, the signature or the
llm_analysis of a symbol is not a hit here — that is search_code.
Text that belongs to NO definition is out of reach — #define,
#include, #ifdef, extern "C", and a file-scope comment. Use
search_content for those.
search_content is the COMPLEMENT of search_bodies, not its fallback.
search_bodies answers which definition and takes the query literally;
search_content answers which files and widens the query. Measured:
SELF_TEST gave 6 files there and 5 definitions here, the extra file
holding the comment Self tester. For a feature footprint, run both.
CITE FROM THE RIGHT FIELD:
• search_bodies / search_content → match_lines holds the lines of the
matches. In search_bodies, line is where the DEFINITION starts,
which in a long function is hundreds of lines away from the match.
Never cite line for a statement.
• get_source / get_file_map → line and end_line are the extent of
the symbol. Cite file:line-end_line. Do not count lines yourself.
• read_file → pass line_numbers=True, or read a window with start_line
and end_line. Its bare content must never be counted.
• find_callers / find_references → line and col of each site; two
calls on one line are two rows.
• A field with NO leading underscore is an answer to cite. An
_-prefixed one (_match_snippet, _fallback) says where it
came from.
Do not leave fw-context for a text search to find a line number.
READ THE RESULT YOU ALREADY HAVE — measured on one session, 4 of 12 calls asked again for what the payload already carried.
Before calling anything for a
path:line, re-read the last result:match_linesandfileare usually already there.Never repeat one query with a filter added. Write
kindin the first call, or readkindon each result.Never invent a symbol name because "it should be called that". Take the name from a result. A guess costs a whole call.
A caller is find_callers, never a comment that reads like one.
UNTRUSTED FIELD — llm_analysis ({summary, inputs, outputs}) is written
by a model, not by the code. It is a hint that points you at a symbol.
NEVER quote it as fact: one measured summary called an identifier
"possibly related to sensor status", which was a guess from its name.
Quote source, signature, or docstring instead.
A NAME THAT MEANS SEVERAL SYMBOLS — a common method name lives in
many classes. read, write, get and size each match dozens
of symbols in a firmware project.
ONE-BODY tools — get_source, get_symbol_context, explain_symbol —
answer for one symbol and add:
• candidates — a row per symbol that the name matched, with
qualified_name, class, kind, file, line and
signature. Pick from it and ask again with that
qualified_name. Read class first: it is what tells two
same-name methods apart.
• candidates_total — how many symbols the name matches
ALTOGETHER. When it is larger than the list, candidates holds
the most referenced ones; lookup_symbol(name, exact=True) lists
them ALL and its offset pages through them. The two orders
differ, thus start that listing at the top — it is not a
continuation of candidates.
• ambiguous_warning — one sentence naming the symbol answered.
LIST tools — find_all_callers_recursive, find_callees_recursive,
find_call_path, find_callers, find_references, find_indirect_call_sites,
find_indirect_targets — answer for ALL of them. A warning row comes
first and names the symbols, and each result carries
target_qualified_name, which tells the symbol it belongs to.
• Read target_qualified_name before you say who calls what.
Without it a caller of one class reads as a caller of the other.
• Give the full qualified name (ClassB::probe) to ask about one
symbol. An exact qualified name always beats a bare sibling.
• lookup_symbol lists every match with its class, and its
offset parameter pages through a name that many classes
share.
HOW EACH TOOL READS YOUR QUERY:
• search_code, search_content — every bare term gets a trailing * and
the terms are OR-joined: "modem init" → modem* OR init*, thus a symbol
with EITHER word matches. Prefer single words.
• search_bodies — the query goes to FTS5 as you wrote it. A space is an
AND of two exact tokens and NO wildcard is added: SELF_TEST misses
Self tester, SELF_TEST* finds it. Add the * yourself.
• Punctuation is not searchable anywhere — FTS5 cannot parse .attach(,
thus it is repaired into a phrase and what runs is the word attach.
search_bodies marks such an answer (_fallback: "sanitized" +
_query_used); the hits whose body really holds the pattern are the
ones with match_lines.
• Underscores are word separators: "modem_init" asks for the two tokens
next to each other and misses modem_parser_oob_init. Write "modem init".
• For exact phrases use double quotes: '"interrupt handler"'.
EMPTY RESULT STRATEGY — an empty list means NO SUCH CODE. A query FTS5
cannot parse comes back as a warning + hint, never as [].
Try a simpler/single-word query in the SAME tool first.
In search_bodies, add the
*— that tool adds none.If search_bodies returns empty, switch to search_content — it widens the query and covers the preprocessor (#define, #ifdef) and extern "C", which belong to no definition and thus reach no symbol body.
Use lookup_symbol for known symbol names.
find_callers gives only an
inforow → no call of the build reaches the function. The answer holds direct calls, assembly calls (originasm), calls through a function pointer (originslotortype_only), calls of an SDK rule (originsdk), and each store of its address. For each other use (areturnof its address), use find_references("function_name"). A unit with a fatal parse error (parse_errors) can lose calls, and code out of the build (a library without source) can call it. For an interrupt handler, use get_vector_table. To find the name in the text, use search_content.Only AFTER exhausting fw-context — use other available tools.
project_only=True (on search_code, search_bodies, search_content, find_dead_code, find_hotspots) excludes vendor SDK code — use it when you ask about YOUR code. The default is not the same on each tool: • search_code, search_bodies, search_content — default False: the answer includes vendor code. • find_dead_code, find_hotspots — default True: the answer holds only project code. Give project_only=False to see vendor code there.
MULTI-PROJECT — a question about a DIFFERENT project: Each tool answers about ONE project. Without project or project_root this is the project of the current directory — NOT the project that the operator asked about.
Call list_projects. It gives the name, the project_id, and the root_path of each indexed project.
Give project="" (or project_root="<root_path>") to EVERY call that follows, get_project_status included. get_project_info is the exception: it takes no project, but the project_id. A name that several projects share gives an error that lists each one with its project_id. Repeat the call with that project_id. Do not invent other parameter names. An unknown argument causes an error that names it.
A PROJECT THAT HOLDS SEVERAL BUILDS — one project can hold several
builds on two axes: variant is the board, image is the program.
A Zephyr project has app, mcuboot and stage0, an ESP-IDF
project has its application and bootloader, and a bootloader is
NOT the application.
ONE QUERY ANSWERS FOR ONE BUILD, AND YOU SELECT IT. A project of
several builds has no active build, and fw-context selects none for
you: no default from the config, no application from the build
system, no completion of a part of a pair. On a project of more
than one build, give the arguments of one build exactly as the
error lists them: the variant, the image, or the two. A query
that names no build, or a part of one, gets an
error that lists each build with the arguments to repeat the call.
An answer that blends a bootloader with an application serves no
question, and two builds of one application repeat nearly every row.
• Select the build from the task. If the task does not identify one
build, ask the user. Do not select a build from its position in a
list.
• get_project_status lists every build in builds, with its state
and counts. get_build_info(variant, image) gives the config_hash,
board, entry_point, memory map and defines of one build. Both read
the INDEX and not only the config, thus a build indexed with
--variant is listed even when config.toml no longer declares it.
• Pass variant and image to every tool that answers about code,
smart_search and semantic_search included.
• To learn whether a symbol is in the bootloader TOO, ask twice, once
per build. Two plain answers beat one blended answer.
• reindex_file is not a query: without variant and image it
re-parses the file in each build that compiles it. Give the
arguments of one build to re-parse only that build.
READING PAST THE FIRST PAGE — each tool that can give a long list
pages it, and says how much there is:
• A list answer leads with a page notice and takes an offset:
lookup_symbol, search_code, search_bodies, search_content,
smart_search, semantic_search, find_callers, find_references,
find_all_callers_recursive, find_callees_recursive,
find_indirect_call_sites, find_indirect_targets, find_variables,
find_dead_code, find_hotspots, find_wrapper_callers,
trace_data_flow, get_template_instances, get_vector_table.
• A dict answer holds the notice under the key page:
get_class_members, get_file_map with kind, and read_file, which
pages LINES and names the next page with start_line, not
offset. get_inheritance_chain (transitive) has all_bases_page
and all_derived_page.
• get_symbol_context and get_source cut each list: <list>_total
counts it, and <list>_hint names the tool that pages a cut list.
• smart_search: no offset, or 0, is a NEW search. A larger offset
pages the stored answer of the last search of the same query.
• semantic_search: total_capped: true means that total is a
lower bound — the search reaches 4096 vector rows at most.
• find_call_path has no pages: the paths cannot be counted. A
trailing info says when paths can be left out.
The notice is {total, offset, shown, more}, plus hint when more
is true. It is ALWAYS
there when the answer holds a row, thus a full page never leaves you
guessing whether more exists.
• Find the notice by its KEYS, not by its position. A warning
row comes before it when the index is stale, and so does the row
that reports a query FTS5 could not parse.
• When more is true, call again with offset=<offset + shown>.
The hint spells out that call, with each argument that changes
the answer: the filters, and the project and the build.
• Do NOT conclude "that is all of them" from one page. Read
total — a hot function can have hundreds of call sites, and a
common name such as read can name hundreds of symbols.
• Each order is stable, thus two pages never overlap and never skip
a row. The tools order by what they answer about: a reference by
file and line, a symbol by definition first, a search by relevance
and then by identity.
• An info row that names an offset means you walked past the end.
PARAMETER NAMES — every tool rejects an unknown argument, thus a guess
costs a whole call. The full schema of each tool is in the tool list.
Read it there. Three names cover almost every tool:
• name — the symbol. NOT symbol, NOT symbol_name.
(lookup_symbol, get_source, get_symbol_context, explain_symbol,
find_callers, find_references, find_all_callers_recursive,
find_callees_recursive, find_indirect_*, find_variables).
Exceptions: find_call_path (from_name, to_name), trace_data_flow
(type_name, to_symbol), find_wrapper_callers and the inheritance
tools (class_name, method_name, template_name).
• file_path — the file. (read_file, get_file_map, reindex_file)
• query — the search terms. (search_code, search_bodies,
search_content, smart_search, semantic_search)
No tool takes a filler argument. Send no argument you did not read in
the schema — get_project_status accepts only project, project_root
and fast.
When a call fails on an argument, DROP the bad argument and REPEAT the
call. Do not continue without the answer, and above all do not skip
get_project_status: it says whether the index can be trusted at all.
ANTI-PATTERNS — do NOT: • Use external search tools for C/C++ symbols → use lookup_symbol or search_code • Use external search tools for code patterns → use search_bodies (function bodies) or search_content (full file content) • Use external tools for callbacks, ISRs → use find_references or search_bodies(project_only=True) • Use file readers for function bodies → use get_source (libclang exact extents) • Use external file readers for C/C++ files → use read_file (returns ifdef-filtered content) • Call get_source + find_callers separately → use get_symbol_context for body, callers, and callees in one call (fewer round-trips, richer data) • Run external search tools in parallel with fw-context • Give up on fw-context after one empty result → try simpler query or different fw-context tool first • search_code for a SINGLE KNOWN symbol → use lookup_symbol(exact=true). search_code FTS5-tokenizes names: "kb_open_disp" → "kb"+"open"+"disp", causing false matches on unrelated symbols containing those tokens. search_code is for concept/keyword DISCOVERY only. • Use generic review agents/skills for C/C++ code → use fw-review skill (see REVIEW SKILL section below).
AGENT LOOP: Check(get_project_status) → Find(search_code/lookup_symbol)
→ Read(get_symbol_context) ← preferred (body+callers+callees in one call).
Fallback: get_source (body only). For whole-file reads: read_file.
→ Trace(find_references/find_callers) — skip if context already from get_symbol_context.
→ For body patterns use search_bodies.
→ DECISION after get_project_status():
• reindex_state of each build in builds — the values of index_state
above. null: the index of that build is current. Continue.
"reindexing" or "pending": wait. "not_scheduled" or "failed": tell
the user the command. Read it for the build that the task needs.
• status="ready" or "reindexing" — queries work. Read reindex_state
of the build before you continue.
• status="reindex_needed" — queries still work, and a reason needs a
command. It wins over "reindexing". When bg_reindex_running=True,
an index run is active or scheduled: do not start a second one.
• client_restart_required=True — NOT a status, and NO command repairs
it. This session does not run the code that it must: the index holds a
newer row format than this session reads, or the operator installed
a different fw-context after this session started. Queries keep
working. Do NOT reindex: the indexer writes the same new format again
and the field comes back. Tell the operator to restart the LLM client
(Claude Code, opencode, or the client in use). The MCP server is a
child process of that client, thus nobody can restart it alone.
client_restart_reason holds the wording.
• update_notice — NOT a status. PyPI has a newer fw-context than the
installed one. Tell the operator one time. Do NOT upgrade it
yourself: the operator knows the tool that installed it.
• status="not_initialized" — project not set up. ASK the operator:
"Initialize fw-context? Runs fw-context init — creates project ID,
config files (.fw-context/config.toml), and registers with AI tools."
Do NOT run without operator confirmation. On approval → run
fw-context init via bash, then call get_project_status() again
(returns no_index). init and index are SEPARATE steps — after init,
ask AGAIN before indexing (see no_index below).
• status="no_index" — project initialized but no symbol index. ASK the
operator: "Build the symbol index? Runs fw-context index --build which
compiles and parses ALL C/C++ source with libclang — takes several minutes
and uses gigabytes of disk." Do NOT run without operator confirmation.
On approval → run fw-context index --build via bash (or
fw-context index <compile_commands.json> if one exists), then call
get_project_status() again to confirm status="ready".
NOTE: init and index are NEVER combined — each requires its own
operator confirmation before execution.
• status="config_error" — a config file of fw-context cannot be used:
it cannot be read, it is not UTF-8 or not valid TOML, a section is
not a table, a key that selects the data or where data goes has a
value of the wrong type, or a URL is not valid. config_file names it,
and index_message gives the problem (for TOML also the line). Tell
the operator the file and the problem. Do NOT run fw-context init
or fw-context index: they cannot repair the file. When
index_message names fw-context doctor --fix --only config, that
command removes each value that cannot be used. Run it, or correct
the file, only with the approval of the operator, then call
get_project_status() again.
• config_warnings (a list, with a status other than config_error) —
values of a config file that fw-context did not use: a lower file
or the default applies, and the tools work. Tell the operator each
line. With the approval of the operator, fw-context doctor --fix --only config removes them.
• analysis.complete: false — the LLM analysis of some symbols is
missing. The tools work, and they give no llm_analysis for those
symbols. When index_message says that symbols wait for the analysis
and names fw-context index, tell the operator, and run it only
with the approval of the operator: the LLM can need hours.
• index_message says that definitions have no embedding — the
search by meaning (semantic_search, smart_search) does not find
them. Tell the operator the command that the message names.
• NO status, only error — the index holds no build config. There is
no status="error".
• The call fails with an error of SQLite (for example "database disk
image is malformed") — fw-context cannot read the index. Call
check_dependencies: the message of its check db-integrity tells if the
database is damaged. Ask the operator before you delete it with
reset_index.
REVIEW WORKFLOW — when reviewing C/C++ code changes (per changed symbol): 0. find_hotspots(project_only=True) — identify highest-impact functions FIRST. Prioritize review of hotspots (20+ callers) over leaf functions.
get_symbol_context(name) — body + direct callers + callees + LLM analysis in one call. Replaces lookup_symbol + find_callers + a list of direct callees.
If the callers are empty → find_references("name") for each use that is not a call, get_vector_table for an interrupt handler, and search_content("name") for code out of the build.
find_all_callers_recursive() → transitive upstream impact (full call tree).
find_callees_recursive() → transitive downstream check. After a logic change, verify compatibility with everything this function calls — arguments, init order, error paths may have changed.
find_references("SymbolName") → all reads/writes/calls of changed types.
search_content("PATTERN") → confirm removal of #define/#ifdef/board names.
find_dead_code() → detect newly dead functions after removal.
trace_data_flow(type_name, to_symbol) → cross-module data dependencies. Use when a changed function produces or consumes typed data that flows through other modules: trace_data_flow("SensorData", "uart_send").
For each search_bodies result set: scan ALL results — the 3rd match may reveal an implementation the diff didn't touch (e.g. duplicate CRC in a private method).
When analyzing BOTH a diff AND fw-context results: diff shows SCOPE (what changed), fw-context verifies CORRECTNESS in full project context. ALWAYS verify diff discoveries recursively with fw-context.
DIFF → FW-CONTEXT VERIFICATION RULE: → When you analyze code via diff (git diff, file diff, patch review), diff shows ONLY what changed — it cannot reveal the impact across the full codebase. → After inspecting a diff: verify your findings with fw-context: • find_references("") — all callers/readers, not just diff context • search_bodies("") — pattern consistency across entire codebase • find_call_path / find_all_callers_recursive — cross-module impact • trace_data_flow("", "") — cross-module data dependencies • find_dead_code / find_hotspots — structural effects of changes → Do NOT draw conclusions from diff results alone — diff is for SCOPE discovery, fw-context is for IMPACT verification. They complement each other; neither replaces the other.
Search: lookup_symbol, search_code, search_bodies (body text), search_content (full file content), smart_search, semantic_search, find_variables. Call graph: find_callers, find_references, find_call_path, find_all_callers_recursive, find_callees_recursive, find_hotspots, find_dead_code, find_wrapper_callers, trace_data_flow, get_vector_table, find_indirect_call_sites, find_indirect_targets. Inheritance: get_inheritance_chain, get_class_members, get_template_instances, get_method_overrides. Source: get_source, get_symbol_context, get_file_map, explain_symbol, read_file. Maintenance: get_project_status, get_build_info, check_dependencies, list_projects, get_project_info, check_ollama, configure_llm, reindex_file, reset_index.
REVIEW SKILL — MANDATORY (not optional): When reviewing C/C++ firmware code (diffs, commits, PRs, changed files), your FIRST action MUST be: skill(name="fw-review") Do NOT use generic review agents (code-explorer, general, etc.) for C/C++ firmware reviews — they do not know fw-context tool selection rules. Do NOT start inline review without the skill. The skill provides: • Phase 0: mandatory review plan creation from diff stat • Phase 1: structural verification (callers, callees, types, inheritance) • Phase 2: logic & memory review (deep code reading — ODR, null deref, call ordering, truncation, state reset, watchdog, edge cases) • Anti-pattern checklist (the common mistakes with fw-context tools) • Tool selection decision tree (search_code vs lookup_symbol, etc.) Trigger phrases — this skill applies to ALL review types regardless of what the user calls it: review, code review, PR review, diff review, deep review, recursive review, exhaustive review, comprehensive review, safety review, audit, change analysis, commit analysis, impact analysis, examine changes, inspect this code, look at this diff, check this PR, check these changes, analyze this commit, verify this change. If the project has a LOCAL fw-review skill, that overrides the global default — the user has intentionally customized it.
Start every session with get_project_status(), and repeat it when the first attempt fails on an argument. An answer built on an index of unknown health is worth nothing. For non-C/C++ files, general-purpose tools are preferred.
LLM SETUP — after get_project_status returns status='ready', call
check_ollama to verify the LLM backend:
• status='ok' — LLM ready. Continue.
• status='not_configured' — Ollama cannot be used, no chat API.
Read message: when the url of the Ollama profile names a
server that is not Ollama, tell the operator to correct that
profile ([llm.profiles.] of ~/.fw-context/config.toml).
Else ASK:
'Use local Ollama or a cloud API?'
- Local: guide operator to install from https://ollama.com.
For intranet: download installer on an internet machine,
copy to local. Do NOT install Ollama yourself.
After operator confirms Ollama is running, call check_ollama.
- Cloud: the operator adds a profile with fw-context llm setup
or fw-context init (URL, model, API key), and stores a key
with fw-context llm key set <name> in a terminal. Then call
configure_llm(profile=). NEVER ask for an API key, and
never run fw-context llm key set: the key must not pass
through this conversation.
If URL is external, ALWAYS warn: source code will be sent
to that endpoint — ensure compliance with data security.
• status='disabled' — [llm] enabled = false. Continue; no LLM calls.
• status='error' — report message to the operator.
• status='model_missing' — Chat or embedding model not installed;
message names each missing model and the command that pulls
it. Each command sets OLLAMA_HOST to the server that must hold
the model, in the syntax of PowerShell on Windows and of a
POSIX shell on other systems. In a different shell (for
example bash on Windows), set OLLAMA_HOST to the same server in
the syntax of that shell, then run ollama pull <model>.
Without OLLAMA_HOST, the model can go to a different server.
YOU estimate download size from model name (your knowledge).
Report to operator with caveat: size may be inaccurate.
ALWAYS ASK: 'Download this model, or configure a separate
cloud chat API (no download needed)?'
- Download by me: run each command of message in your shell.
On failure, check stderr for network errors (timeout,
unreachable, no such host). If network issue: suggest
offline install — pull on internet machine, copy
~/.ollama/models/, or download GGUF + ollama create.
- Download manually: tell operator to run each command of
message (NOTE: outside normal flow). Include offline
instructions for intranet.
- Cloud API: the operator adds a profile with fw-context llm setup or fw-context init, then call
configure_llm(profile=).
• status='model_missing' + suggest_cloud=true — No model
≥7B parameters installed (too small for code tasks).
Check model_details for installed models. Emphasize cloud
API option.
• status='embedding_unavailable' — Chat works (cloud) but
embedding needs Ollama, and Ollama cannot be used. Warn:
semantic search disabled. message names the cause: offer
to guide Ollama setup, or to correct the url of the Ollama
profile of the embeddings ([llm] embed_profile).
• compliance_warning present (check_ollama: in chat_api, and
embedding_compliance_warning for embeddings of an API;
configure_llm: at the top level) — ALWAYS show to operator.
Recommend local or internal API first.
Model downloads are LARGE (multi-GB). ALWAYS ask before pulling.
auto_pull defaults to false — no automatic downloads on 404.
Model size estimates are YOUR judgment — always caveat to operator.
configure_llm writes ONLY to /.fw-context/local.toml
(gitignored). It does NOT modify global or shared config files.
configure_llm returns status='error' — report the error message
to the operator. If the test call failed, the operator can do a test
of the profile with fw-context llm test <name> (a request without
code), and see which place gives its API key with fw-context llm key status <name> (never the key).
A failed call restores the previous local.toml, thus nothing changed —
fix the issue and call configure_llm again.
configure_llm returns status='error' with 'not initialized' —
tell operator to run 'fw-context init' in the project root first.
Stream option: when the chat API is behind a reverse proxy (nginx,
Cloudflare, corporate proxy) that kills idle connections, the operator
sets stream = true in the profile ([llm.profiles.] of
~/.fw-context/config.toml). configure_llm has no stream parameter.
With stream, the client sends stream:true and reads SSE chunks, which
keep the connection alive. Default false — non-streaming
is sufficient for local Ollama. When false, SSE responses are still
auto-detected and parsed as a fallback.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| check_dependenciesA | Run the dependency audit of the installation. Read-only, and it creates no file. Call it when get_project_status or another tool reports a problem of
the installation, or before the first Each entry gives what to do in In a project that is not initialized, only the checks of the installation run: the Python packages, SQLite, libclang and its headers. The LLM, model, database and disk checks need the config. The check Args: project_root: Project root directory. Auto-detected from CWD if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. Returns:
list[dict]: one dict per check, each with |
| check_ollamaA | Check whether the LLM backend is running and the configured embedding/chat model is installed. Read-only: yes. No side effects. Call before smart_search, semantic_search, or explain_symbol (when on-demand fallback is expected — pre-computed analysis returns instantly without the LLM backend). Args: project_root: Project root. Auto-detected if omitted. Used to locate the project's LLM configuration. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. Returns:
dict: {ollama_enabled (bool), status (str — "ok"|"disabled"|
"not_configured"|"model_missing"|"embedding_unavailable"|"error"),
ollama_running (bool), ollama_url (str), configured_model (str),
num_ctx (int), installed_models (list[str]),
chat_api (dict — What to do for each status:
WHY these rules are here and not only in the server instructions: an LLM client can cut the instructions of a server (Claude Code keeps approximately 2500 characters), and it always sends the description of a tool. |
| configure_llmA | Select the LLM profile (and the embedding model) of the current project. Writes to WHY no URL and no key here (since the profiles, 2026-10-20): a key that an MCP call writes passes through the conversation of the LLM client, and a URL that a tool call sets can send the source code to any host. Args:
project_root: Project root directory. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
profile: The name of a profile of the global config.
embed_model: Embedding model: an Ollama tag, a sentence-transformers
name ( Returns: dict: {status ("ok"|"error"), profile (str), provider (str), chat_api (dict — configured, endpoint, format, model), model (str), auto_pull (bool), stream (bool), context (int, for a profile of an API or of the ChatGPT plan: the context of the model in tokens), test_latency_s (float, on success), test_response (str, on success), compliance_warning (str, when the chat goes to another host), message (str)} |
| get_build_infoA | Return the detail of ONE build: its identity, its health, its memory map and its defines. Read-only with the two exceptions that The health fields ( About
This is the configuration the BUILD states, not every macro the
preprocessor saw. The second is three orders of magnitude larger —
27800 distinct names on the STM32 project — and almost all of it comes
from the headers and the compiler. A Zephyr build keeps its real
configuration in Args: project_root: Project root directory. Auto-detected from CWD if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. fast: When True (default), the header check reuses the cached manifest hashes. False recomputes them. Returns:
dict: {variant, image, board, config_hash, project_id, project_root,
build_system, compile_commands, indexed_at (str — UTC),
first_indexed_at, symbol_count, file_count, reference_count,
modified_files_count, header_affected_tus, parse_errors (dict or
None — see get_project_status), manifest_verification,
analysis, description, vendor_paths, project_paths,
effective_vendor_patterns (list[str] — the SQL LIKE patterns that
this build really used to mark vendor code, for example
|
| get_project_infoA | Return project metadata (name, type, root_path) for a project ID. Looks up the global project registry at Read-only. No side effects. Args: project_id: Project ID (UUID4 hex) to look up. Returns: dict: {project_id, name, project_type, root_path, created_at, updated_at} or {"error": "..."} when the project_id is not registered. |
| get_project_statusA | MANDATORY FIRST CALL for C/C++ projects. Return the health of the index of the project, and the list of its builds — check it before you use any other fw-context tool, and call it again while you wait for a reindex. Read-only with two exceptions, and it spawns no subprocess — the
startup daemon thread and the file watcher own the background reindex.
The exceptions: the last index run can leave a marker that says that
the build is not there, and when the tool finds that build again, it
removes the marker. It also removes a
Act on
Each query answer carries the state of its build as
A project of several builds gets the worst status of its builds. A
reason that every build gives comes one time, and any other reason
names its build: A failure sets NO Seven conditions set
Args:
project_root: Project root directory. Auto-detected from CWD if
omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
fast: When True (default), the header check reuses the cached
manifest hashes. Both modes run the per-file scan, thus
Returns:
dict: {project_id, project_root, build_system, schema_version (int
— DB schema version), current_schema (int — code expects),
vendor_paths (list[str] — config index.vendor_paths),
project_paths (list[str] — config index.project_paths),
status (str — "ready"|"reindexing"|"reindex_needed"|"no_index"|
"not_initialized"|"config_error"; a failure sets no status and
gives |
| list_projectsA | List all indexed firmware projects with their statistics. Read-only. No side effects. Use it to find another project; call
A project of several builds gets no counts here (
Args:
project_root: Project root whose config names the index
directory ( Returns: list of dicts, each with: project_id, name, root_path, build_system, symbol_count, file_count, indexed_at (str — UTC), description (str), first_indexed_at (str — UTC), schema_version, current_schema, reindex_needed (bool — the schema is outdated, the compile_commands.json of a build changed or is missing, or a build holds rows of an older row format; each (variant, image) build counts), status (str — "ready" or "reindex_needed"), db (path to SQLite database file), build_count (int — number of builds, each a (variant, image) pair), analysis (dict — LLM-analysis coverage {project: {analyzed, skipped, total}, vendor: {analyzed, skipped, total}}, or None when no build is indexed). |
| reindex_fileA | Re-parse a single source file with libclang and update its symbols in the index. Not read-only — uses the exact compiler flags from Without The call runs in a thread of the server and sends a notice each 5 s.
It holds the lock of the query tools: another query waits 5 s, then
gets "server busy". After 300 s the call returns an A source file must be listed in Each re-parse writes only the files that the parsed unit owns, as an index run does. When a header that the unit includes changed on disk and a different unit owns that header, the tool also re-parses that owner, thus the changed header gets its new rows. Also rebuilds the method override relationships, the PageRank scores
and the hotspot cache when reference indexing is on
( Args:
file_path: Path to the file to re-parse. A source file must be in
compile_commands.json; a header goes through one including unit.
project_root: Project root directory. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
variant: The variant of the one build to re-parse. Omit it, and
A file that is gone from disk but still in the index has its records removed in each build that holds it; the result is then {file, symbols_removed, action: "deleted", builds}. Returns:
dict: {file, translation_units, symbols_updated, elapsed_s, builds},
plus builds_without_file when a build does not compile the file.
|
| reset_indexA | Delete the entire symbol index for a project. Not read-only — permanently deletes the SQLite database and WAL files.
Call with Handles corrupt databases gracefully — you can delete a corrupt index without needing to open it first. Args: project_root: Project root directory. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. confirm: Must be True to execute. Call without first as dry-run. Returns:
dict: {project_root, db, project_id, action: "dry_run"|"deleted",
message, build_count, symbol_count, indexed_at}. |
| lookup_symbolA | Look up a C/C++ symbol by name via libclang index — exact or prefix
matching. Finds symbols text-based search can miss: build-conditional
code, template instantiations, macro-expanded names. Macros are
extracted via name matches the name or the qualified name. A name with Read-only: yes. May auto-reindex stale files (non-blocking). Args:
name: Symbol name (exact match) or prefix (set exact=False).
E.g. 'uart_init' finds the exact function; 'uart_' finds
all symbols starting with 'uart_'.
project_root: Project directory. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
exact: True = exact name match, False = prefix LIKE match (default).
limit: Maximum results of one page (default 50, max 100).
offset: Skip this many results (default 0). A common method name
lives in many classes — Returns:
list[dict]: The page notice leads the answer — |
| search_codeA | 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 Use when you know the concept but not the exact name
( Results hold the metadata of each symbol — name, location, signature, docstring — not its implementation code. FTS5 syntax:
Progressive relaxation: when a step matches nothing, the next one
runs. Six steps can run. Step 1 is the primary path and its results
carry NO
Steps 3-6 ignore Kind filter values: Local variables are out. FTS5 indexes the qualified name, thus a
local matches through the function that holds it: a query for
After Read-only: yes. May auto-reindex stale files (non-blocking). When a file that the answer names changed on disk, this tool starts the watcher daemon in the background and answers from the index it has. Args: query: FTS5 search terms. Keep queries short — 1–3 words. project_root: Project root directory. Auto-detected from CWD if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. kind: Optional filter to return only symbols of this kind. limit: Maximum results of one page (default 20, max 100). offset: Skip this many results. Reads the next page of a topic that many symbols carry; the page notice names the offset to use. One relaxation step owns the whole answer, thus a walk never changes the step under the reader. project_only: When True, exclude vendor SDK directories and return only application code. Default False. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
list of dicts. The page notice leads the answer — |
| search_bodiesA | Find patterns in the TEXT OF A DEFINITION — the code inside its extent. Searches ifdef-filtered text — only the code that compiles for the
build of the query. A line of an inactive Searches the stored text of every definition (
A match on a type reports the type as the result, thus a query for one
enum constant answers with the enum, and Only the text matches. The query is bound to the stored body: a
hit in the NAME, the signature, the docstring or the When to use
The query goes to FTS5 as you wrote it. This tool alone adds no wildcard, and that is what keeps a pattern precise:
Limitation — the extent of a definition is the boundary. Text that belongs to no definition is out of reach:
For those, use Set Results include Read-only: yes. Requires the FTS5 index. May auto-reindex stale files
(non-blocking) — see Args:
query: FTS5 search terms, 1-3 words. A bare multi-word query is an
AND of exact tokens, and no wildcard is added — see the query
rules above. A single word is the broadest form: Returns:
list of dicts. The page notice leads the answer — |
| search_contentA | Find patterns in FULL file content — the whole file, not only the text that belongs to a definition. Searches ifdef-filtered file text — only code that actually compiles
for the build of the query. Inactive Covers the text that belongs to no definition, which is what
Not a fallback of
For the footprint of one feature, run both. Results are file-level — one entry per matching file, with
When Read-only: yes. Requires the FTS5 index with file content. May
auto-reindex stale files (non-blocking) — see Args:
query: FTS5 search terms. 1-3 words. Bare multi-word queries are
OR-joined (prefix-wildcarded). Prefer single-word queries.
E.g. Returns:
list of dicts. The page notice leads the answer — |
| semantic_searchA | Semantic search using pre-computed libclang symbol embeddings. Finds
symbols by meaning, not by text — matches concepts even when query
words don't appear literally in the code. Uses cosine similarity over
variable-dimension embeddings generated during When to prefer over search_code: When you're describing a concept rather than searching for a known keyword. Examples:
When to prefer search_code instead: When you know the exact keyword
or symbol name ( Threshold guidance (mxbai-embed-large model):
Source-aware ranking: the similarity of a project symbol is
multiplied by 1.2, and the similarity of every other symbol by 0.85.
The index marks each file as project code or not, thus the two tiers
are all there are. The multiplied score sets the order.
Requires Read-only. No side effects. Args: query: Natural language description of what you're looking for. Be specific — 5–15 words works best. project_root: Project root. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. threshold: Minimum cosine similarity (0.0-1.0). Default 0.60. The tool applies it to the raw cosine similarity, before the source boost. limit: Maximum number of results on one page (default 20, max 100). offset: Skip this many results. Reads the next page; the page notice names the offset to use. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
The page notice |
| smart_searchA | Natural-language search: an LLM generates FTS5 keywords, then searches the libclang index. Finds concepts by meaning rather than exact text match. Prefer this when you don't know the exact keywords and want to describe what you're looking for ("how does the modem connect?", "handle BLE pairing failure"). Read-only: yes. Slow (10-30 s) — delegates to the full
Multi-phase approach:
When to prefer over search_code: When you don't know the exact keywords and want to describe what you're looking for ("how does the modem connect?", "handle BLE pairing failure"). Fallback: When LLM is unavailable, falls back to direct FTS5 search
with word-split terms from the query. When the LLM call or the
embedding step fails, a metadata dict gives the reason in Args: query: Natural language description of what you're looking for. Be specific — 5–15 words works best. project_root: Project root directory. Auto-detected from CWD if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. limit: Maximum number of results on one page (default 20, max 100). The search itself always ranks up to 100 symbols. offset: Skip this many results of the previous search of the same query. 0, the default, is a NEW search. A page with an offset comes out of the stored answer of the last search; when the last search was of another query (or another project, or a build that a reindex changed), the tool searches again first. An index run that keeps the build keeps the stored answer. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
list of dicts with metadata entries (_generated_queries, _rough_queries,
_translated_from + _translated_to), then the page notice
|
| find_all_callers_recursiveA | Find all transitive C/C++ callers — who calls name, directly or indirectly, through the libclang call graph including function-pointer edges, implicit constructors, and the edges of the SDK model. libclang-powered: follows function-pointer assignments and ISR vector registrations across the full call tree. Use for impact analysis: "if I change this function, how far does the
ripple go?" Returns callers at depth 1 (direct), depth 2 (callers of
callers), up to Edge types traversed: Includes Limitation — calls without a target: a call that libclang cannot
resolve (a dependent call in a template that is never instantiated)
has no edge, because fw-context does not take a target from a name.
A construction that the source does not write has no edge either: the
default construction of a member, and the member constructions of an
implicit constructor. If you suspect a missing caller, verify with
For a flat, single-level caller list use Read-only. No side effects. Requires the reference index
( Args: name: Symbol name to find transitive callers of. project_root: Project root. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. max_depth: Maximum BFS depth for transitive search (default 5). limit: Maximum results (default 50). offset: Skip this many results. Reads the next page of a deep call tree; the page notice names the offset to use. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns: list of dicts, each with: name (str — the caller), qualified_name (str), kind (str), signature (str), depth (int — distance from the target), file (str — absolute). |
| find_call_pathA | Find call paths between two C/C++ functions via BFS in the libclang call graph, including function-pointer edges, ISR vector registrations, implicit constructors, and the edges of the SDK model (a task that the scheduler starts). libclang-powered: follows function-pointer edges and ISR vector registrations that text-based search cannot resolve. Use to answer "how does A reach B?" — e.g. tracing how a high-level
event handler eventually calls a low-level driver. Returns up to 5
distinct paths in BFS order (short paths first), each with Edge types traversed: The BFS includes Limitations:
On an empty result that you expected to hold a path: look for async
dispatch ( For one-sided exploration use Read-only. No side effects. Requires both symbols to be in the index
and refs enabled ( Args:
from_name: Starting symbol for path search.
to_name: Target symbol to find path to.
project_root: Project root. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
max_depth: Maximum BFS depth for path search (default 10). The
search runs from both ends, and each end goes up to
Returns:
At most 5 paths, each a dict with: depth (edge count, int), chain (str —
e.g. |
| get_vector_tableA | Read the interrupt vector table, and say what services each interrupt. The vector table is how an interrupt reaches code. Nothing CALLS a handler — the hardware reads a slot and jumps — so a handler has no caller, and every other tool shows it as unreferenced. This tool reads the table itself, from the assembly the build compiles. Use it to answer "which interrupts does this firmware service", to find the handler for one interrupt, or to find the interrupts that reach the trap loop. The slot number is the position in the table. What that position
means belongs to the architecture, not to the index. On Cortex-M
slots 0 to 15 are the system exceptions and slot 16 + n is external
interrupt n, so The
A Three sources are read, and
Recognition is by shape, never by name, so any array of function
addresses is reported and the row names its table. A table of
interrupt handlers and a table of state machine steps are the same
construct, and Slot numbers are not joined across tables. Each slot is the index
inside its own table, so two tables both start at 0 — read A Read it in both directions. A hole in a table of handlers is a vector
nothing services. A hole in Zephyr's An The complement is taken over the length of the table, NOT over the
slots that hold a stub. Measured on an mcuboot image: its software
table names 44 of 48 slots, and one of those 44 is
What is still not covered: an architecture that builds its table from
branch instructions (arm64, Xtensa, MIPS) writes no table of
addresses in either form. A handler whose address the build resolved
at link time has no name to report either — Read-only. No side effects. Requires an index of the assembly and the
reference index ( Args:
project_root: Project root. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
unhandled_only: When True, return only the Returns:
The page notice |
| find_callees_recursiveA | Find all transitive C/C++ callees — what name calls, directly or indirectly, through the libclang call graph including function-pointer edges, implicit constructors, and the edges of the SDK model. libclang-powered: follows function-pointer calls and indirect invocations across the full dependency tree. Use for dependency analysis: "what does this function depend on to do
its job?" Returns callees at depth 1 (direct), depth 2 (callees of
callees), up to Edge types traversed: Includes Limitation — calls without a target: a call that libclang cannot
resolve (a dependent call in a template that is never instantiated)
has no edge, because fw-context does not take a target from a name.
If you suspect a missing callee, verify with
For direct callees only, Read-only. No side effects. Requires the reference index
( Args: name: Symbol name to find transitive callees of. project_root: Project root. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. max_depth: Maximum BFS depth for transitive search (default 5). limit: Maximum results (default 50). offset: Skip this many results. Reads the next page of a deep call tree; the page notice names the offset to use. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns: list of dicts, each with: name (str — the callee), qualified_name (str), kind (str), signature (str), depth (int — distance from the source), file (str — absolute). |
| find_callersA | Find who calls a C/C++ function — direct calls AND indirect via
function pointers, callbacks, and struct/array init lists (such as a
vector table that the build generates in C). libclang-powered: detects
function-pointer assignments that text-based search cannot see.
A slot of an assembly vector table ( Falls back to macro lookup when the symbol is not found as a function/method: returns the macro definition (kind="macro") and files that use it (ref_kind="macro_use"). Use when you need a quick, flat list of immediate callers. For the full
transitive call tree (who calls this indirectly through other functions),
use Read-only. No side effects. Requires the reference index
( Indirect edges (
Args:
name: Symbol name to find callers of. Uses the same three-tier
resolution as Returns:
The page notice first — |
| find_dead_codeA | Find C/C++ functions that are defined but never called — libclang-powered dead code detection across the entire indexed codebase. Distinguishes called from uncalled symbols globally, not just within a single file — text-based search cannot determine whether a function is actually reachable. What "dead" means: zero references of any The
A call that reaches a function by its type only (origin
fw-context records the constructor call of an object at namespace or
class scope as an ISRs: a handler that an assembly vector table names ( Other known false positives: constructors from factories, virtual method overrides, and weak-aliased symbols. Always verify before you delete.
Read-only. No side effects. Requires the reference index
( Args:
project_root: Project root. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
limit: Maximum results of one page (default 100, max 200).
offset: Skip this many results. Reads the next page; the page
notice names the offset to use.
exclude_paths: Additional LIKE patterns to exclude (user-supplied
tool parameter, not config). E.g. Returns:
The page notice first — |
| find_hotspotsA | Find the most-called C/C++ functions ranked by caller count — libclang call-graph hotspot detection. Identifies functions with the most architectural weight — good targets for refactoring, optimization, or extra testing. Text-based search cannot aggregate caller statistics across the full call graph. Use for high-level impact assessment: changing a hotspot affects many call sites. The result tells you which functions carry the most "architectural weight" across the entire codebase. By default, SDK/vendor paths are auto-excluded so hotspots reflect
project code. Use For the callers of a specific hotspot, follow up with Read-only. No side effects. Requires the reference index
( Args:
project_root: Project root. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
limit: Number of top-called functions per page (default 20, max 50).
offset: Skip this many results. Reads further down the ranking;
the page notice names the offset to use.
project_only: When True (default), filters to Returns:
The page notice first — |
| find_indirect_call_sitesA | Find the indirect calls through a C/C++ function pointer field or variable, or the indirect calls that a function makes, with the functions that each call reaches. An indirect call goes through a slot: a field, a variable, a
parameter or the return value of a function that holds a function
( Read-only. No side effects. Use this to answer "where is this function
pointer invoked, and what does it call?" as opposed to
Requires the reference index ( Args: name: A function pointer field or variable, or a function, method or lambda. Resolved as every symbol tool resolves a name (qualified name, bare name, suffix); a name of several symbols answers for each of them. A parameter is no symbol: ask with its function. project_root: Project root directory. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. limit: Maximum results (default 50, max 200). offset: Skip this many results. Reads the next page; the page notice names the offset to use. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
list of dicts, one per call site, each with: file, line, col,
caller, caller_kind, kind ( |
| find_indirect_targetsA | Find the functions that a C/C++ function pointer field or variable can hold, and where the code stores each of them; or, for a function, where the code stores its address and which indirect calls reach it. The answer comes from the data flow of the build, not from names: a
function reaches a field when the code stores it there, or stores it
in a slot whose value flows there (an argument of For the calls through the pointer, use Read-only. No side effects. Requires the reference index
( Args: name: A function pointer field or variable, or a function, method or lambda. Resolved as every symbol tool resolves a name; a name of several symbols answers for each of them. project_root: Project root directory. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. limit: Maximum results (default 50, max 200). offset: Skip this many results. Reads the next page; the page notice names the offset to use. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
For a field or a variable, one dict per function: function, kind,
file and line (the definition), origin ( |
| find_referencesA | Find ALL references to a C/C++ symbol — calls, reads, member accesses,
function pointer registrations, vector table slots, and macro
usages. libclang-powered: detects function-pointer registrations
(vector table entries, callback attachments, Falls back to macro lookup when the symbol is not found as a function/method: returns the macro definition (kind="macro") and files that reference it (ref_kind="macro_use"). Read-only. No side effects. Returns every reference in the indexed codebase,
including call sites, variable reads, struct member accesses, indirect
function-pointer references, and macro usages. Requires the reference
index ( For direct callers only use Args: name: Symbol name to find all references of. project_root: Project root directory. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. limit: Maximum results of one page (default 50, max 200). offset: Skip this many results. Reads the next page of a symbol with many references; the page notice names the offset to use. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
The page notice first — |
| find_wrapper_callersA | Find C/C++ wrapper classes that call methods of a driver class —
libclang-powered adapter pattern detection. Traces method ownership
across class boundaries to reveal the wrapper/adapter architecture
(e.g. Returns wrapper methods grouped by wrapper class, showing which driver
methods each wrapper calls. Useful for understanding the adapter/wrapper
architecture (e.g. For the reverse perspective — finding who calls a specific driver method
— use Read-only. No side effects. Requires the reference index
( Args:
class_name: Driver class name to find wrappers for.
E.g. Returns:
list of dicts, each with: wrapper_class (str — |
| trace_data_flowA | Trace how C/C++ data of a given type flows to a target function via libclang call paths. libclang-powered: finds functions by type signature and maps call paths through the full call graph, which text-based search cannot trace across translation units. Finds definitions whose signature mentions type_name (substring match, any symbol kind, most-called first), then looks for call paths from those to to_symbol. Returns a data flow map — useful for understanding how a data structure travels through the system to its destination. Works best for synchronous driver stacks (e.g. sensor read → I2C write).
Cannot follow async flows (message queues, interrupts, RS485 callbacks).
For exact call-graph queries use the Read-only. No side effects. Requires the reference index
( Args:
type_name: Type name to trace. E.g. Returns:
The page notice |
| explain_symbolA | Explain what a C/C++ symbol does in plain English — libclang-aware
analysis. Uses pre-computed LLM analysis when available (instant),
falls back to on-demand LLM. Falls back to macro explanation when
the name matches a Read-only. No side effects — uses pre-computed LLM analysis when available
(instant, generated during For raw source code use Args:
name: Symbol name to explain. E.g. Returns:
dict: {name, kind, file, line, signature, explanation, llm_analysis
(if pre-computed)}. With no pre-computed analysis and no LLM
(disabled), the dict holds |
| get_file_mapA | Fast structural map of all C/C++ symbols in a file grouped by kind — libclang-powered table of contents. Like a table of contents before reading a chapter: see what functions, classes, and enums a file defines at a glance. The index decides which file a path may reach: a path that no file of this build answers for is refused, and a header of the SDK that the build compiles is reachable like any file of the application. Pass a path relative to the project root ( Enum constants ( For detailed symbol information use Read-only. No side effects. Use before reading a large file to orient yourself — see what functions, classes, and enums it defines. Args:
file_path: Path relative to project root, or just the filename.
project_root: Project directory. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
signatures: Include full function signatures. Default: False.
max_per_kind: Max items per kind group (default 30, 0 = unlimited).
With Returns: dict: {file, total_symbols, symbols: {kind: {count, items[], subgroups?[]}}} |
| get_sourceA | Read a C/C++ function/method/enum/macro body using libclang exact extents — no guessing line numbers. Uses AST-precise {start, end} extents so you get exactly the function body. Generic file readers don't know where a function actually ends — libclang tracks exact {start, end} from the AST. The body is ifdef-filtered: a line of an inactive For enums, includes a For rich context (who calls this, what does it call) use
Read-only. No side effects. Args:
name: Symbol name, or qualified name ( Returns:
dict: {name, qualified_name, kind, file, line, signature,
docstring, is_definition, is_template, is_virtual, is_pure_virtual,
source (str — the function/enum/macro body, truncated at 8000 chars),
warning (str, optional — when source file cannot be read)}.
May also include |
| get_symbol_contextA | Rich one-shot context for a C/C++ symbol: body, signature, the direct callers and callees. Answers "what does this do and how does it fit in the system?" in a single response — libclang powers the call graph, not regex. Falls back to macro display when the symbol is not found. Prefer this over The callers and callees include vendor/SDK code — the call graph
naturally spans project and vendor boundaries in both directions
(project → vendor API, vendor callback → project handler). Each list
is cut (callers at 50, callees at 100), and its The body is ifdef-filtered, the same as in Read-only. No side effects. Args: name: Symbol name. Returns body, signature, the direct callers and callees (each list with its total). project_root: Project root. Auto-detected if omitted. project: Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. variant: Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build. One query answers for ONE build. image: Image of the build: a separate program, such as the application or the bootloader. Give it when the build has an image name. Returns:
dict with: name, qualified_name, kind, file, line, signature,
docstring (raw Doxygen comment text), is_definition, callers (list,
max 50 — |
| read_fileA | Read a C/C++ source file, one page at a time, with ifdef-filtered content —
only code that actually compiles for the build of the query.
Inactive Use this to read a file without leaving the fw-context ecosystem.
Unlike generic file readers, this tool returns build-accurate content:
code gated behind A blank line is an answer, and not a defect: it says that the line is
in a branch the build does not take. When EVERY line of the file is
blank, the dict carries
Without A comment and a preprocessor directive are part of the answer. Both
are text that the file holds and the build reads, thus both stay — an
include guard, a For reading a single function body with libclang exact extents use
Read-only. No side effects. Falls back to raw disk content (with a
warning) when the indexed Args:
file_path: Path relative to project root, or just the filename.
E.g. Returns:
dict: {file (str), language (str — |
| get_class_membersA | Return all methods, fields, and nested types of a C/C++ class/struct — libclang-powered member table. Groups members by kind (method, constructor, field, enum, etc.), distinguishing class members from free functions across the entire codebase. Members are grouped by kind (method, constructor, destructor, field, enum, typedef, class, struct). Each member includes its signature, virtual flags, and source line. Works for C structs too — they just won't have methods. For inheritance hierarchy use Read-only. No side effects. Args:
class_name: Class or struct name. E.g. Returns: dict: {name, qualified_name, kind, file, line, members: {kind: [{name, qualified_name, signature, is_virtual, is_pure_virtual, line}]}, member_count (int — every member), page} |
| get_inheritance_chainA | Return the C++ inheritance chain for a class or struct — libclang-aware hierarchy. Resolves base/derived class relationships across all translation units, which single-file reading cannot do. Shows direct base classes (what this inherits from) and direct derived classes (what inherits from this), along with access level and virtual flag for each edge. When For class members use Read-only. No side effects. Args:
class_name: Class or struct name to get inheritance information for.
E.g. Returns: dict: { name, qualified_name, kind, file, line, bases: [{name, usr, access, is_virtual, file}], derived: [{name, usr, access, is_virtual, file}], all_bases: [{name, usr, access, is_virtual, depth, file, kind}] (when transitive=True, ancestors sorted by depth, then name), all_derived: [...] (when transitive=True, descendants, same shape) } |
| get_method_overridesA | Return C++ virtual method override information — libclang-powered vtable analysis. Resolves virtual dispatch across class hierarchies: shows which base-class method this overrides, and which derived-class methods override this one. Text-based search cannot resolve virtual dispatch across translation units. Shows what base-class method this method overrides, and what derived-class
methods override this one. Built from the For class-level inheritance, use Read-only. No side effects. Args:
method_name: Method name to get override information for. Use
qualified name for disambiguation, e.g.
Returns: dict: { name, qualified_name, kind, file, line, signature, overrides: [{usr, name, qualified_name, kind, file, line}], overridden_by: [{usr, name, qualified_name, kind, file, line}] } |
| get_template_instancesA | Find all template instantiations for a C/C++ class or function template — libclang template-aware lookup. Finds concrete instantiations spread across all translation units, each with its full type signature. Text-based search cannot resolve template specializations across translation units. Returns concrete instantiations of the template — each with its full type
signature (e.g. Uses the Known limitation: libclang's For finding the template declaration itself use Read-only. No side effects. Args:
template_name: Template name to find instantiations for.
E.g. Returns:
list[dict]: the page notice |
| find_variablesA | Find C/C++ variables by name or part of it and trace who reads or
writes them through the call graph. libclang-powered: splits
variables into global ( Each result includes a type signature ( Use when you need to understand shared state, find who modifies a
global variable, trace side effects, or distinguish important globals
from loop counters. For general symbol search use This tool is the way to a LOCAL variable: Legacy indexes with Read-only. No side effects. Args:
name: Variable name or part of it. Substring match on name and
qualified name (e.g. Returns:
list of dicts, each with: name (str), qualified_name (str),
kind (str — |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| resource_stats | Return a human-readable markdown summary of all indexed projects. Read-only. Aggregates stats from every project database found under the configured index directory. |
| resource_projects | Return project list as a JSON string. Read-only. Uses the same data as ``list_projects``, serialized as indented JSON. |
| resource_embedded_review_skill | Return the fw-review SKILL.md as an MCP resource. Read-only. Makes the embedded firmware review methodology available to any MCP client via a well-known resource URI. |
TDQS
Scored across 37 tools
The tool descriptions are unusually detailed and often explicitly point to alternatives, but several families still overlap: search_code/search_bodies/search_content, lookup_symbol/find_variables, find_callers/find_references/recursive call tools, and get_source/get_symbol_context/read_file. With 37 tools, an agent can still misselect within those clusters despite the cross-references.
Names consistently follow a verb_noun or verb_object pattern: find_*, get_*, search_*, check_*, configure_*, read_*, trace_*, explain_*, lookup_*. The casing and structure are predictable throughout the visible set.
37 tools is large for a code-context server. While many are specialized, the surface exceeds the 25-tool threshold and likely could consolidate related operations or expose some variants as parameters.
The server covers core C/C++ firmware analysis well: symbol search, references, call graphs, indirect calls, classes, inheritance, templates, dead code, hotspots, data flow, file reading, and LLM/dependency checks. Minor gaps remain around explicit index/lifecycle operations and a few advanced analysis queries.