Skip to main content
Glama

get_inheritance_chain

Obtains the C++ inheritance chain for a class: lists direct bases and derived classes, and when enabled, walks the full hierarchy up and down with cycle detection.

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 'zbox::ZMODEM'. 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 'zbox::ZMODEM'.
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, the description fully discloses behavior: read-only with no side effects, BFS with cycle detection for diamond inheritance, and a detailed return structure. This adds significant value beyond the schema and annotations.

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-loaded with purpose and key capabilities, well-structured into paragraphs. Some technical details (e.g., 'BFS with cycle detection') could be considered excessive, but overall efficient.

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?

Fully covers the tool's functionality given its complexity (transitive walking, multiple parameters, diamond inheritance). No output schema, but the description provides a complete return structure specification.

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%, and the description adds context beyond the schema: examples for class_name, auto-detection note for project_root, and clamping range for max_depth. Adds meaningful value.

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 uses a specific verb ('Return') and resource ('inheritance chain'), and clearly differentiates from siblings by mentioning alternative tools (get_class_members, get_method_overrides) that serve different purposes.

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

Usage Guidelines4/5

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

Provides explicit context: mentions that single-file reading cannot do this, and suggests alternative tools for class members and method overrides. However, it does not explicitly state when NOT to use this tool beyond those cases.

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