Skip to main content
Glama

reindex_file

Update an edited C/C++ file's symbols in the index without a full rebuild by re-parsing it with compile_commands.json flags.

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.

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 that includes it, taken from the manifest of each build. 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.

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, overrides_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``.

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. The method overrides, the PageRank scores and the hotspot cache are rebuilt in the two modes when reference indexing is on (`[index] index_refs`).

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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"
      +}
  2. 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"
      +}
  3. Changed1 schema field changedv0.32.0
    • addedInput schema / properties / file_path / minLength
      Added value: +1
  4. 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."
  5. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and discharges it: it states this is not read-only, that it holds the query-tool lock (another query waits 5s then gets 'server busy'), the 300s timeout with partial work, the 5s notices, header staleness warnings, and that it rebuilds overrides/PageRank/hotspot cache plus content-addressed LLM analysis.

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

Conciseness4/5

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

Front-loads the core purpose and organizes the rest into prose plus Args/Returns sections. It is long, but the length is justified by genuine complexity (6 params, multi-build behavior, no output schema), with only mild duplication between the prose and the Returns block.

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?

No output schema and no annotations, so the description must cover returns and behavior — and it does: it details the returned dict shape, per-build aggregation rules, failed_builds, and failure/error cases. All six parameters are documented, so nothing needed to call it correctly is missing.

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, but the description adds real meaning: the variant/image pairing error, the project-vs-project_root exclusivity, and the with_analysis=True/False cost tradeoff. It largely mirrors the schema's own descriptions, hence not a 5.

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 precise verb+resource+effect: 'Re-parse a single source file with libclang and update its symbols in the index.' This clearly distinguishes it from siblings like reset_index (full rebuild) and the read-only query tools, so an agent can place it immediately.

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

Usage Guidelines5/5

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

Explicit when-to-use: 'Use after editing a file to keep the index current without a full rebuild.' It names the alternative (full 'fw-context index') and the condition that selects it, and spells out when to supply variant/image versus omitting them.

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