Purpose: fw-context-mcp provides build-aware code intelligence for AI coding assistants working with embedded C/C++ firmware. It builds a persistent semantic index based on compile_commands.json and the libclang AST, then exposes it to coding agents via MCP, letting agents query the program structure actually produced by a given build rather than inferring it solely by repeatedly reading source files and doing text searches.
Main capabilities: The index includes symbol definitions, signatures, source ranges, and documentation; references, direct call edges, and recursive caller paths; function pointer assignments and indirect call sites; callback registration and invocation relationships; active file contents after preprocessor filtering; macro parameters, replacement text, and expanded values; inheritance, overriding, and virtual dispatch relationships; translation units and project/vendor metadata; optional embeddings and LLM-generated summaries. It can answer questions such as whether an implementation is active in the current build, who directly or indirectly calls a function, where callbacks are registered, which function pointer assignments can reach a call site, which code is excluded by the preprocessor, the impact scope of an API change, and the execution flow from an ISR to application code.
Usage: Requires Python 3.11 or later, a project that can generate compile_commands.json, and an MCP-capable coding agent (such as Claude Code or OpenCode). Installation via pip is recommended, or the current source version can be installed; then register fw-context for the supported coding agents detected in the project, build and index the firmware, and after restarting the agent you can ask questions. The index is persistent and incremental, reprocessing only changed translation units after the first run. Ollama is optional: the core index (symbols, full-text search, call graph, source) depends only on libclang and SQLite; under the default configuration Ollama also computes vector embeddings (semantic_search, smart_search reranking) and symbol analysis (explain_symbol, symbol descriptions), and when not enabled these features fall back to full-text search or return the original prompt.
Applicable scenarios: build-aware review of firmware commits, execution tracing across ISRs/work queues/tasks/callbacks, locating all callers and references of an API, identifying the implementation selected by the current build, impact analysis before changing a function signature or data type, navigating unfamiliar firmware without reading entire files, finding dead code candidates and unreferenced symbols, distinguishing project code from SDK/vendor code, reducing irrelevant comment text sent to the model. Supports Zephyr, PlatformIO, Mbed OS, Arduino, ESP-IDF, generic CMake, Makefile projects, and custom builds that can provide a compilation database; there are also configuration paths for Keil, IAR, STM32CubeIDE, and TI Code Composer Studio.
Limitations: The project interface and indexing behavior are still evolving; it is suitable for real embedded projects but may encounter unsupported build configurations or incorrect results. The project is local-first, with source code and compiler-derived indexes kept on the developer's machine unless optional external services are explicitly configured. It does not replace clangd: clangd is suited for interactive editing, while fw-context is aimed at persistent, structured, reusable context for AI agents. The materials do not provide specific fee or pricing information.