Skip to main content
Glama

reindex_file

Re-parses a single source or header file with libclang and updates its symbols in the project index using exact compile_commands.json flags, so edits stay current without a full rebuild.

Instructions

Re-parse a single source file with libclang and update its symbols in the index.

Not read-only — uses the exact compiler flags from compile_commands.json. Use after editing a file to keep the index current without a full rebuild.

Without variant and image the file is re-parsed in EACH build of the project that compiles it: an edit on disk changes the file for every build of the tree. A build that does not compile the file is named in builds_without_file. With the two arguments of one build, as get_project_status lists them, only that build is re-parsed; a part of a pair gets an error that lists the builds.

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 error, and a part of the work can continue or fail. Call get_project_status for the state of each build, and repeat the call for a build that is not current. The answer holds no index_state, except when a manual fw-context index run holds the index (see Returns).

A source file must be listed in compile_commands.json. A header is not listed there — compile_commands.json names translation units — so it is re-parsed through one unit of each build. A header goes to the unit that owns it in the index (the unit that wrote its rows in the last index run). Only a header without an owner goes to an including unit from the manifest. That answer describes a single compilation context, thus the result carries a warning: another unit can see the header under a different set of #define values and still hold stale symbols. Only a full fw-context index covers every context. One unit and not all of them is a cost decision — an application header reaches a median of 3 units but as many as 266 on a real project, at tens of seconds each.

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 ([index] index_refs), with and without with_analysis. When with_analysis=True and the LLM is on ([llm] enabled), it also regenerates the LLM analysis and the embeddings of the affected symbols. The analysis also needs [llm] analyze_symbols. It is content-addressed, thus an unchanged symbol is never re-analysed.

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 image, to re-parse each build that compiles the file. image: The image of the one build to re-parse. with_analysis: When True (default), also regenerates the LLM symbol analysis and the embeddings, which need a model. Set False for a fast update: the status tools then report the symbols that wait for the two.

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. builds has one entry for each build that compiles the file: {variant, image, translation_units, symbols_updated, elapsed_s}, plus when they apply: skipped_tus and skipped_count (units that failed to parse), warning (header coverage), analysis_updated and embeddings_updated (counts for the whole build, not this file), and analysis_warning, slot_edges_warning, pagerank_warning, or embedding_warning when a phase failed, or error when the re-parse of that build failed.

When one build compiles the file, the top level holds the full
result of that build.  When several do, the top level holds the
sums of the builds that did not fail, ``elapsed_s`` of the whole
call, the sum of ``skipped_count``, ``warning`` only when each of
those builds has it, and ``failed_builds`` with the label of each
build whose entry holds ``error``.

On failure the dict holds ``error`` with the reason: a refusal of
the selector, no build that compiles the file, or an update that
failed in each build.  It can add ``skipped_tus`` or ``action``.

When another process holds the index of the project, the tool
does nothing and ``error`` names it.  A manual ``fw-context index``
run adds ``index_state: "reindexing"``: wait for its end, then call
again.  ``fw-context analyze`` does not change the index of the
code: do not wait for it; the index of the file stays old until an
index run reads it.  A background index run is no reason: the tool
stops it, and the daemon runs it again after the tool.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "file_path": "<file_path>"
    },
    "name": "reindex_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
imageNoImage of the one build to re-parse: a separate program, such as the application or the bootloader. Give it when that build has an image name.
projectNoProject 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.
variantNoVariant of the one build to re-parse. Omit it and image to re-parse the file in each build that compiles it. A part of a pair gets an error that lists the builds.
file_pathYesAbsolute or project-relative path to the file to re-parse. A source file must have an entry in compile_commands.json. A header is re-parsed through one translation unit that includes it, and the result then carries a warning that other units can still hold stale symbols.
project_rootNoProject root directory. Auto-detected from cwd if omitted. This field also accepts a project name or a project_id, but project is the clear field for those.
with_analysisNoWhen True (default), also regenerates the LLM symbol analysis and the embeddings — slower, because the two need a model. Set False for a fast update: the tool skips the two, and get_project_status then reports the symbols that wait for them. In the two modes, the tool resolves the indirect calls again and rebuilds the PageRank scores and the hotspot cache when reference indexing is on (`[index] index_refs`).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.36.0
    • changedInput schema / properties / with_analysis / description
      Previous value: -"When True (default), also regenerates the LLM symbol analysis and the embeddings — slower, because the two need a model. Set False for a fast update: the tool skips the two, and get_project_status then reports the symbols that wait for them. The method overrides, the PageRank scores and the hotspot cache are rebuilt in the two modes when reference indexing is on (`[index] index_refs`)."New value: +"When True (default), also regenerates the LLM symbol analysis and the embeddings — slower, because the two need a model. Set False for a fast update: the tool skips the two, and get_project_status then reports the symbols that wait for them. In the two modes, the tool resolves the indirect calls again and rebuilds the PageRank scores and the hotspot cache when reference indexing is on (`[index] index_refs`)."
  2. Changed3 schema fields changedv0.35.0
    • changedInput schema / properties / file_path / description
      Previous value: -"Path to the file to re-parse. A source file must be in compile_commands.json. A header goes through one translation unit that includes it, and the result then carries a warning about the other units."New value: +"Absolute or project-relative path to the file to re-parse. A source file must have an entry in compile_commands.json. A header is re-parsed through one translation unit that includes it, and the result then carries a warning that other units can still hold stale symbols."
    • changedInput schema / properties / project_root / description
      Previous value: -"Project root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those."New value: +"Project root directory. Auto-detected from cwd if omitted. This field also accepts a project name or a project_id, but project is the clear field for those."
    • addedInput schema / properties / with_analysis
      Added value: +{
      +  "default": true,
      +  "description": "When True (default), also regenerates the LLM symbol analysis and the embeddings — slower, because the two need a model. Set False for a fast update: the tool skips the two, and get_project_status then reports the symbols that wait for them. The method overrides, the PageRank scores and the hotspot cache are rebuilt in the two modes when reference indexing is on (`[index] index_refs`).",
      +  "title": "With Analysis",
      +  "type": "boolean"
      +}
  3. Changed2 schema fields changedv0.32.1
    • addedInput schema / properties / image
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Image of the one build to re-parse: a separate program, such as the application or the bootloader. Give it when that build has an image name.",
      +  "title": "Image"
      +}
    • addedInput schema / properties / variant
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Variant of the one build to re-parse. Omit it and image to re-parse the file in each build that compiles it. A part of a pair gets an error that lists the builds.",
      +  "title": "Variant"
      +}
  4. Changed1 schema field changedv0.32.0
    • addedInput schema / properties / file_path / minLength
      Added value: +1
  5. Changed4 schema fields changedv0.30.0
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / file_path / description
      Previous value: -"Path to source file to re-parse. Must be in compile_commands.json."New value: +"Path to the file to re-parse. A source file must be in compile_commands.json. A header goes through one translation unit that includes it, and the result then carries a warning about the other units."
    • addedInput schema / properties / project
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "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.",
      +  "title": "Project"
      +}
    • changedInput schema / properties / project_root / description
      Previous value: -"Project root. Auto-detected if omitted."New value: +"Project root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those."
  6. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations at all, the description carries the full burden and does so thoroughly: it declares 'Not read-only', the compiler-flag source, threaded execution, 5 s notices, the query-tool lock and 'server busy' behavior, the 300 s timeout with partial work, index-lock conflicts, and which files get written. It even explains that a background index run is stopped and re-run by the daemon.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the critical not-read-only warning are front-loaded, and the Args/Returns structure is scannable. However, it is very long and repeats schema-documented parameter text (file_path, project, variant) in the Args block, and the Returns section is dense prose rather than a compact shape summary.

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?

For a six-parameter mutation tool with no annotations and no output schema, the description covers everything an agent needs: selection semantics, cost/latency, timeout and lock behavior, header coverage limitations, and a full return-shape contract including per-build and aggregated forms plus error cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description goes beyond by explaining the variant/image pairing rule ('a part of a pair gets an error that lists the builds'), the project-vs-project_root exclusivity, and the cost rationale behind with_analysis. The header-vs-source path semantics for file_path add real meaning beyond the schema text.

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?

Opens with a specific verb+resource: 'Re-parse a single source file with libclang and update its symbols in the index.' The scope is explicitly distinguished from a full rebuild ('without a full rebuild', 'Only a full fw-context index covers every context'), so an agent can tell it apart from reset_index without inspecting either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'Use after editing a file to keep the index current without a full rebuild' gives a clear when-to-use condition, and the header paragraph plus the 300 s guidance give when-to-repeat/when-to-avoid rules. It does not explicitly name a sibling alternative (e.g. reset_index) as the escalation path, only the CLI command, so it stops short of full routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.