Skip to main content
Glama

get_template_instances

Finds all concrete instantiations of a C/C++ template across translation units, using libclang to resolve specializations. Returns full type signatures and the template declaration.

Instructions

Find all template instantiations for a C/C++ class or function template — libclang template-aware lookup. Finds concrete instantiations spread across all translation units, each with its full type signature. Text-based search cannot resolve template specializations across translation units.

Returns concrete instantiations of the template — each with its full type signature (e.g. Callback<void(int)>). The template declaration itself is also returned as the first result when found.

Uses the template_usr column populated during indexing via libclang's cursor.specialized_template.

For finding the template declaration itself use lookup_symbol.

Read-only. No side effects.

Args: template_name: Template name to find instantiations for. E.g. 'Callback' or 'mbed::Callback'. project_root: Project root. Auto-detected if omitted. limit: Maximum results (default 50).

Returns: list[dict] with one element wrapping the template declaration: {name, qualified_name, kind, file, line, is_definition, signature, instances (list of dicts, each with name, qualified_name, kind, file, line, signature, is_definition), instance_count (int)}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum results (default 50).
project_rootNoProject root. Auto-detected if omitted.
template_nameYesTemplate name to find instantiations for. E.g. 'Callback' or 'mbed::Callback'.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations, description fully covers behavioral aspects: declares 'Read-only. No side effects', explains the underlying mechanism (uses `template_usr` column from libclang's `cursor.specialized_template`), and notes that the template declaration is returned as the first result. Could mention performance implications, but current detail is strong.

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?

Description is well-structured with clear paragraphs and an example. It is slightly lengthy but each sentence adds value, covering purpose, usage, behavior, and return format. Could be tightened, but remains effective.

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?

Given the presence of an output schema (noted in context signals), the description complements it well by detailing the return structure (list of dict with fields like name, qualified_name, signature, instances, etc.). No major gaps are apparent for a tool of this complexity.

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 description coverage is 100%, so baseline is 3. Description provides examples for `template_name` (e.g., 'Callback' or 'mbed::Callback') and clarifies auto-detection for `project_root` and default for `limit`. This adds some meaning beyond the schema but does not significantly exceed what the schema already conveys.

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?

Description clearly states the tool's purpose: 'Find all template instantiations for a C/C++ class or function template'. It specifies the resource (template instantiations) and distinguishes from sibling tools like `lookup_symbol` (for finding the template declaration). The verb 'find' and resource are specific and unambiguous.

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 provides when-to-use and when-not-to-use guidance: 'For finding the template declaration itself use `lookup_symbol`.' Also explains why this tool is superior to text-based search for resolving template specializations across translation units, giving clear context for appropriate usage.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/turbyho/fw-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server