Skip to main content
Glama

get_type_hierarchy

Get the full type hierarchy for a Java type: superclasses, interfaces, and subtypes. Find types by cursor position or qualified name.

Instructions

Get the type hierarchy (supertypes and subtypes) for a Java type.

USAGE: Position on a type, returns full inheritance chain OUTPUT: Superclasses, interfaces, and all subtypes

Can be called with either:

  • File position (filePath, line, column) - finds type at cursor

  • Type name (typeName) - looks up type by qualified name

IMPORTANT: Uses ZERO-BASED coordinates when using file position.

unresolvedSupertypes, present only when there are any, names each supertype the compiler cannot resolve (a missing dependency), as the declaration writes it, with the type whose declaration names it: this type or one of its supertypes. The superclasses then run to the last that resolves and end with java.lang.Object. potentialMatches are the places naming the type, or a subtype, as a supertype that JDT could not confirm.

maxResults, the most entries each of superclasses, interfaces and subtypes lists (totalSuperclasses, totalInterfaces and totalSubtypes count all of them, and meta.truncated says when a list is cut), is 1 to 50; outside that range is INVALID_PARAMETER.

potentialMatches, present only when there are any, holds the places JDT's search reports as possible matches but cannot confirm, because a type or name there does not resolve (a missing dependency or a compile error): count is their exact number, and locations lists them, as many as the results it stands beside may list. They are never counted or listed as results.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
lineNoZero-based line number
columnNoZero-based column number
filePathNoPath to source file (for position-based lookup)
typeNameNoFully qualified type name (alternative to position)
maxResultsNoMost entries each list holds, 1 to 50 (default 10)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.5.3
    • removedInput schema / properties / maxDepth
      Removed value: -{
      -  "description": "Maximum depth of hierarchy to return (default 10)",
      -  "type": "integer"
      -}
    • addedInput schema / properties / maxResults
      Added value: +{
      +  "description": "Most entries each list holds, 1 to 50 (default 10)",
      +  "type": "integer"
      +}
  2. Addedv1.3.4
  3. Removedv1.3.3
  4. First observedv1.2.0

TDQS

A4.2/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so well: it documents zero-based coordinates, the 1-50 maxResults bound with an INVALID_PARAMETER error for out-of-range values, truncation via meta.truncated, conditional unresolvedSupertypes/potentialMatches fields, and a load_project prerequisite. This is unusually rich behavioral disclosure for a read tool.

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

Conciseness3/5

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

The purpose and usage are front-loaded, but the output paragraphs are dense, convoluted run-on sentences (e.g., the nested maxResults clause with parenthetical total counters) and repeat details already present in the schema. It is information-rich but not tightly written.

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?

There is no output schema, so the description must explain return values, and it does: superclasses, interfaces, subtypes, totals, truncation flags, unresolvedSupertypes, and potentialMatches semantics. An agent has everything needed to call and interpret the tool 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 meaning beyond the schema: it explains that filePath/line/column and typeName are alternative lookup modes, reinforces zero-based coordinates, and specifies the INVALID_PARAMETER consequence of an out-of-range maxResults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Get the type hierarchy (supertypes and subtypes) for a Java type,' and the OUTPUT line clarifies it returns the full inheritance chain. It does not explicitly distinguish itself from overlapping siblings like find_implementations, get_type_members, or analyze_type, so it falls short of a 5.

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?

The USAGE line and the two-mode explanation (file position vs typeName) tell the agent how to invoke it, and 'Requires load_project to be called first' supplies a clear prerequisite. However, it gives no when-to-use-vs-alternative guidance relative to siblings such as find_implementations, so no exclusions are stated.

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