Skip to main content
Glama

get_file_map

Generate a structural map of C/C++ symbols in a file, grouped by kind (functions, classes, enums), to preview its contents before reading.

Instructions

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 (src/main.cpp) or just the filename (main.cpp). The exact path wins; else the path matches whole trailing path segments (config.h matches src/config.h, not hw_config.h), a project file before a vendor file, then the shortest path. Returns symbols keyed by kind (function, method, class, struct, enum, ...). Each kind has count (total) and items (first N, default 30). Set max_per_kind=0 for unlimited, signatures=true for full sigs.

Enum constants (enum_constant) are grouped into subgroups by parent enum. Each subgroup has name, count, and constants (list of {name, qualified_name, line, enum_value}). The subgroup count reflects the real total even when max_per_kind limits the constants list.

For detailed symbol information use get_symbol_context or lookup_symbol.

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 kind, the size of the page. kind: One symbol kind, for example "function" or "enum_constant". Gives one page of the items of that kind instead of the map. offset: With kind: skip this many items of that kind. Reads the next page; page 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: dict: {file, total_symbols, symbols: {kind: {count, items[], subgroups?[]}}}

Each item holds ``name``, ``qualified_name``, and ``line``, plus
``end_line`` when the symbol is a definition.  The two line numbers
are the extent, thus ``file:line-end_line`` is the citation.  A
group that ``max_per_kind`` cut holds ``hint``, the call that pages
its items.

With ``kind``: {file, kind, count, items[], page}, where ``items``
is one flat page of that kind, enum constants too, and ``page`` is
the page notice ``{total, offset, shown, more, hint}``.  A page
after the last item gives one ``info`` dict that names the total.

When the file changed after the last index run, the dict adds
``stale`` (True) and ``stale_warning`` (str).

On failure the dict holds ``error`` with the reason (plus the stale
keys when indexed files changed).

Input Schema

NameRequiredDescriptionDefault
kindNoOne symbol kind, e.g. 'function' or 'enum_constant'. Gives one page of the items of that kind.
imageNoImage of the build: a separate program, such as the application or the bootloader. On a project of more than one build, give it when that build has an image name, as the refusal lists it.
offsetNoWith kind: skip this many items of that kind. Reads the next page.
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 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 for you. One query answers for ONE build.
file_pathYesPath to source file — relative to project root or just filename.
signaturesNoInclude full function signatures in output.
max_per_kindNoMax items per symbol kind group (default 30, 0 = unlimited). With kind, the size of the page.
project_rootNoProject root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv0.32.1
    • changedInput schema / properties / image / description
      Previous value: -"Sysbuild image within the variant. Required when the variant holds several: each image is a separate program."New value: +"Image of the build: a separate program, such as the application or the bootloader. On a project of more than one build, give it when that build has an image name, as the refusal lists it."
    • addedInput schema / properties / kind
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "One symbol kind, e.g. 'function' or 'enum_constant'. Gives one page of the items of that kind.",
      +  "title": "Kind"
      +}
    • changedInput schema / properties / max_per_kind / description
      Previous value: -"Max items per symbol kind group (default 30, 0 = unlimited)."New value: +"Max items per symbol kind group (default 30, 0 = unlimited). With kind, the size of the page."
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "With kind: skip this many items of that kind. Reads the next page.",
      +  "minimum": 0,
      +  "title": "Offset",
      +  "type": "integer"
      +}
    • changedInput schema / properties / variant / description
      Previous value: -"Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build."New value: +"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 for you. One query answers for ONE build."
  2. Changed4 schema fields changedv0.32.0
    • addedInput schema / properties / file_path / minLength
      Added value: +1
    • changedInput schema / properties / image / description
      Previous value: -"Sysbuild image name within the variant (multi-project). Omit for all images of the variant."New value: +"Sysbuild image within the variant. Required when the variant holds several: each image is a separate program."
    • addedInput schema / properties / max_per_kind / minimum
      Added value: +0
    • changedInput schema / properties / variant / description
      Previous value: -"Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants."New value: +"Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build."
  3. Changed3 schema fields changedv0.30.0
    • addedInput schema / additionalProperties
      Added value: +false
    • 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."
  4. Changed2 schema fields changedv0.25.3
    • addedInput schema / properties / image
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Sysbuild image name within the variant (multi-project). Omit for all images of the variant.",
      +  "title": "Image"
      +}
    • addedInput schema / properties / variant
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants.",
      +  "title": "Variant"
      +}
  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?

No annotations are provided, so the description carries the full burden and does so thoroughly: read-only/no side effects, the index's reachability/refusal rule, the path-matching precedence algorithm, stale-file detection with stale/stale_warning keys, and error-dict behavior. This is far more than the structured fields convey.

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?

Well front-loaded with purpose first, then path rules, then returns. The Returns block is justified since no output schema exists, but the Args block largely duplicates the 100%-covered schema, adding some redundancy to an otherwise disciplined structure.

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 9-parameter tool with no output schema and no annotations, the description supplies the missing return shape, pagination mechanics, build-selection requirements, and failure modes. An agent has everything needed to invoke and interpret results correctly.

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: exact-path-wins matching with whole-trailing-segment fallback, project-vs-project_root mutual exclusivity ('Give one of the two, not both'), and how variant/image select one build. It stops short of fully documenting offset/page interplay beyond what the schema states.

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?

States a specific verb and resource ('Fast structural map of all C/C++ symbols in a file grouped by kind'), reinforced by the concrete 'table of contents' analogy. It explicitly distinguishes itself from detail-oriented siblings by naming get_symbol_context and lookup_symbol. An agent can select it without opening the schema.

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?

Explicitly routes the agent: 'Use before reading a large file to orient yourself' and 'For detailed symbol information use get_symbol_context or lookup_symbol.' It also explains when to use project vs project_root and to call list_projects for names. Both when-to-use and alternatives are covered.

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