Skip to main content
Glama

find_unused_code

Identify unused private methods and fields in Java projects to clean up code and reduce technical debt. Analyzes write-only fields and unused members for removal.

Instructions

Find unused private methods and fields in the project.

USAGE: find_unused_code() USAGE: find_unused_code(filePath="path/to/File.java") OUTPUT: List of unused private members

Detects:

  • Unused private methods

  • Unused private fields

  • Write-only fields (set but never read)

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathNoOptional: specific file to check (default: all files)
includeMethodsNoInclude unused methods (default true)
includeFieldsNoInclude unused fields (default true)
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what the tool detects (unused private methods/fields, write-only fields) and the prerequisite (load_project), but doesn't mention performance characteristics, limitations (e.g., false positives with reflection), or what happens when no unused code is found. It provides basic behavioral context but lacks depth for a complex analysis tool.

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 well-structured with clear sections (purpose, usage, output, detection scope, prerequisite). It's appropriately sized at 6 lines, though the 'USAGE:' lines could be more concise. Every sentence adds value, but there's minor redundancy in listing detection categories that could be streamlined.

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?

For a code analysis tool with 3 parameters, no annotations, and no output schema, the description does a good job covering the essentials: purpose, usage patterns, output format, detection scope, and prerequisites. It could be more complete by describing the output format in more detail (structure of the list) and mentioning any limitations, but it provides sufficient context for basic usage.

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 all three parameters. The description mentions the filePath parameter in usage examples but doesn't add meaning beyond what's in the schema descriptions. It doesn't explain the includeMethods/includeFields parameters at all. Baseline 3 is appropriate when the schema does the heavy lifting.

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 clearly states the tool's purpose: 'Find unused private methods and fields in the project' with specific details about what it detects (unused private methods, unused private fields, write-only fields). It distinguishes itself from sibling tools like 'find_references' or 'find_field_writes' by focusing specifically on unused private members rather than general usage analysis.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: it shows two usage patterns (with and without filePath parameter), specifies that 'load_project' must be called first as a prerequisite, and distinguishes when to use this tool (for finding unused private members) versus other analysis tools in the sibling list that serve different purposes like control flow or dependency analysis.

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/pzalutski-pixel/javalens-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server