Skip to main content
Glama
pkp124

cmake-build-model

by pkp124

Find how a file is built

find_file_targets
Read-only

Find CMake targets that compile a source file; return language, standard, flags, defines, includes, and exact compiler commands. For headers, match targets whose include paths contain them.

Instructions

Finds which targets (in which build directories and configurations) compile a given source file, and returns the effective language, standard, flags, defines and include directories from the File API together with the exact compiler command(s) from the build directory's compile_commands.json. For headers not listed as sources, returns targets whose include directories contain the file. Searches all known build directories unless buildDir is given.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the file (absolute or relative to a workspace root).
buildDirNoBuild directory (absolute, or relative to a workspace root). A source directory with a single build directory is also accepted. May be omitted when the workspace has exactly one build directory.
configurationNoBuild configuration (e.g. Debug, Release) for multi-config generators. Defaults to the first one.
includeBacktracesNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description adds genuine context beyond them: it reads from the File API plus compile_commands.json, defaults to scanning all build directories, and covers the header-not-a-source case. It omits failure behavior for unknown files and any mention of result size or pagination.

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?

Three sentences, purpose front-loaded, with the return payload detailed second and the header/buildDir caveats last. Dense but nearly every clause carries information; the header clause in particular earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description does the work of naming what comes back, and read-only safety is covered by annotations. It stops short of describing the shape of the result (per-target vs per-command grouping) or behavior when no targets match.

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

Parameters3/5

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

Schema coverage is 75%, so the schema already documents most parameters. The description largely restates schema semantics (buildDir omission, default configuration) rather than adding new meaning such as path resolution edge cases or includeBacktraces effects.

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?

The description states a precise verb+resource ('Finds which targets ... compile a given source file') and enumerates the returned artifacts (language, standard, flags, defines, include dirs, compiler commands). It is clearly distinguishable from siblings like get_compile_commands (raw commands) and list_targets (all targets) because it performs a file-to-target mapping.

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

Usage Guidelines3/5

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

It explains search scope ('Searches all known build directories unless buildDir is given') and the header special case, which implies when it applies. However, it never names an alternative tool or states when NOT to use it, so routing between it and get_compile_commands remains inferred.

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