Skip to main content
Glama

get_inheritance_chain

Resolve C++ inheritance relationships across translation units. Returns direct bases and derived with access/virtual flags; transitive mode walks full ancestor and descendant chains.

Instructions

Return the C++ inheritance chain for a class or struct — libclang-aware hierarchy. Resolves base/derived class relationships across all translation units, which single-file reading cannot do.

Shows direct base classes (what this inherits from) and direct derived classes (what inherits from this), along with access level and virtual flag for each edge.

When transitive=True, walks the full hierarchy up to all ancestors and down to all descendants (bounded by max_depth). Uses BFS with cycle detection to handle diamond inheritance.

For class members use get_class_members. For virtual method override chains use get_method_overrides.

Read-only. No side effects.

Args: class_name: Class or struct name to get inheritance information for. E.g. 'UART_DRIVER' or 'comm::MODEM'. project_root: Project root. Auto-detected if omitted. transitive: When True, walk the full inheritance tree both up (ancestors) and down (descendants). Default: False (direct bases and derived only). max_depth: Maximum BFS depth for transitive walk (default 10, clamped to 1–50).

Returns: dict: { name, qualified_name, kind, file, line, bases: [{name, usr, access, is_virtual, file}], derived: [{name, usr, access, is_virtual, file}], all_bases: [...] (when transitive=True, ancestors sorted by depth), all_derived: [...] (when transitive=True, descendants sorted by depth) }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_depthNoMaximum BFS depth for transitive walk (default 10).
class_nameYesClass or struct name to get inheritance information for. E.g. 'UART_DRIVER' or 'comm::MODEM'.
transitiveNoWhen True, walk the full inheritance tree both up (ancestors) and down (descendants). Default: False (direct bases and derived only).
project_rootNoProject root. Auto-detected if omitted.
Behavior5/5

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

With no annotations provided, the description carries full burden. It states 'Read-only. No side effects.' and describes the BFS algorithm with cycle detection for diamond inheritance, plus the transitive edge-case behavior. This is exemplary disclosure of behavioral traits.

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

Conciseness5/5

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

The description is detailed yet well-organized: a one-sentence purpose, a scoping note, edge-case behavior, alternatives, read-only declaration, structured Args, and a clear Returns dict. Every section earns its place without fluff.

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?

Given the tool's complexity (transitive hierarchy, BFS, cycle detection) and the absence of an output schema, the description compensates fully by providing the exact return structure. It also covers cross-TU limitations and parameter behavior, making it self-sufficient.

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 adds useful examples for class_name ('UART_DRIVER' or 'comm::MODEM') and clarifies the clamping of max_depth. Most parameter details mirror the schema, but the examples and structural hints push it slightly above baseline.

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 opens with a specific verb ('Return') and resource ('C++ inheritance chain for a class or struct'), immediately clarifying the tool's scope. It explicitly distinguishes itself from siblings by noting it works across translation units and by naming alternatives like get_class_members and get_method_overrides.

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?

The description provides clear when-to-use context: it handles cross-TU inheritance resolution that single-file reading cannot. It also gives explicit exclusions and alternatives: 'For class members use get_class_members. For virtual method override chains use get_method_overrides.' This fully orients the agent.

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