Skip to main content
Glama

find_instanceof_checks

Find all instanceof checks for a fully qualified Java type to analyze type discrimination and find polymorphism opportunities.

Instructions

Find all instanceof checks for a type (x instanceof Foo).

JDT-UNIQUE: This fine-grained search is not available in LSP.

USAGE: Provide fully qualified type name OUTPUT: All locations where instanceof checks against this type occur

Useful for:

  • Identifying type checking patterns

  • Finding polymorphism opportunities (replace instanceof with virtual dispatch)

  • Understanding type discrimination logic

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
typeNameYesFully qualified type name to find instanceof checks for
maxResultsNoMaximum results to return (default 100)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.4
  2. Removedv1.3.3
  3. First observedv1.2.0

TDQS

A4.2/5.0
Behavior4/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 substantial work: it discloses the OUTPUT shape, the load_project prerequisite, and a detailed semantics note that potentialMatches are unresolved/unconfirmed matches never counted or listed as results. It omits any statement about truncation behavior relative to maxResults, keeping it just under 5.

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?

The core purpose, uniqueness note, usage, and output are front-loaded before the longer potentialMatches explanation. The potentialMatches paragraph is verbose for the value it adds, but every part is relevant and no sentence is filler.

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 correctly supplies the return semantics: where instanceof occurrences are reported and how the anomalous potentialMatches collection is structured and counted. Combined with the prerequisite and input format, an agent has everything needed to call and interpret this tool.

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 both typeName and maxResults are already documented in the schema. The description only restates 'fully qualified type name' for typeName and says nothing new about maxResults, so the baseline 3 applies.

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?

States a precise verb+resource ('Find all instanceof checks for a type') and even disambiguates the syntax being matched with the example '(x instanceof Foo)'. The 'JDT-UNIQUE: not available in LSP' note plus the narrow construct focus clearly separates it from siblings like find_casts, find_type_instantiations, and find_references.

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?

Gives a concrete prerequisite ('Requires load_project to be called first') and an input instruction ('Provide fully qualified type name'), plus a useful-for list that implies when the tool applies. It does not explicitly name alternative tools (e.g., find_casts vs find_instanceof_checks) or state when NOT to use it, so it falls short of a 5.

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