Skip to main content
Glama

find_annotation_usages

Locate all usages of a Java annotation by providing its fully qualified type name, returning every code location where it is applied.

Instructions

Find all usages of an annotation type in the project.

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

USAGE: Provide fully qualified annotation name as typeName OUTPUT: All locations where the annotation is applied

Examples:

  • find_annotation_usages(typeName="org.springframework.beans.factory.annotation.Autowired")

  • find_annotation_usages(typeName="org.junit.jupiter.api.Test")

  • find_annotation_usages(typeName="javax.persistence.Entity")

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 annotation type name (e.g., 'org.springframework.beans.factory.annotation.Autowired')
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.1/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 behavioral disclosure burden. It explains output semantics well, including the special `potentialMatches` field, its relation to unresolved types, and that those matches are never counted as real results. It could add more on permissions or result format, but the unusual search behavior is covered.

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 description is front-loaded with purpose and usage, then examples, then edge-case output behavior, and finally the prerequisite. The `potentialMatches` paragraph is somewhat wordy but earns its place because no output schema exists to explain that field.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple search operation, the description is nearly complete. It covers the input requirement, output locations, the special `potentialMatches` semantics, and the `load_project` prerequisite. It omits only minor return-detail or pagination specifics already implied by `maxResults`.

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 the schema already documents both `typeName` and `maxResults`. The description reinforces that `typeName` must be fully qualified and gives multiple examples, but this largely duplicates the schema's own example and does not add syntax or format details beyond it.

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 states a specific verb and resource: finding all usages of an annotation type in the project. It also explicitly notes a differentiator, JDT-UNIQUE, indicating why this search is distinct from LSP-based sibling tools. An agent can identify the tool's purpose without opening the schema.

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?

It gives clear usage context: provide a fully qualified annotation name as `typeName`, and load_project must be called first. It does not explicitly say when not to use this tool or name an alternative sibling like find_references, but the annotation-specific scope is clear.

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