Skip to main content
Glama

find_casts

Find all explicit casts to a fully qualified Java type, so you can identify unsafe downcasts and refactoring opportunities.

Instructions

Find all casts to a type ((Foo) x expressions).

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

USAGE: Provide fully qualified type name OUTPUT: All locations where casting to this type occurs

Useful for:

  • Identifying unsafe downcasts

  • Finding refactoring opportunities (replace cast with polymorphism)

  • Understanding type conversion patterns

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 casts to
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 provided, the description carries the full burden and does so well: it documents the OUTPUT shape, the tricky potentialMatches semantics (possible-but-unconfirmed matches, never counted as results), and the load_project prerequisite. It does not explicitly state read-only/safety behavior, but 'find' plus the read-only nature is strongly implied.

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 the one-line purpose, then clearly sectioned USAGE/OUTPUT/Useful-for blocks. The potentialMatches paragraph is dense but earns its place by clarifying an otherwise confusing output edge case. Minor redundancy with the schema keeps it from a 5.

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?

With no output schema, the description correctly supplies return-value semantics, including the potentialMatches structure and its count/locations fields, and states the load_project prerequisite. An agent has everything needed to invoke and interpret results correctly.

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's 'Provide fully qualified type name' only restates the schema's typeName description and says nothing about maxResults, so it adds no meaning beyond the structured fields. Baseline 3 is appropriate.

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 specific verb+resource ('Find all casts to a type') and even supplies the syntactic form ((Foo) x). It positions itself against the broader toolset by noting the search is fine-grained and unavailable in LSP, so an agent can distinguish it from siblings like find_references or find_instanceof_checks.

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 clear when-to-use context via the 'Useful for' list (unsafe downcasts, refactoring, conversion patterns) and a hard prerequisite ('Requires load_project to be called first'). It stops short of naming alternative sibling tools or stating when not to use it, so it is context-rich but not fully routing.

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