Skip to main content
Glama

find_unreachable_code

Analyze Java projects to identify code unreachable from declared entry points like main methods and test methods. Use results to detect dead code while noting reflection and DI may be invisible.

Instructions

Find code unreachable from any entry point, project-wide.

USAGE: find_unreachable_code() OUTPUT: Members (types, methods, fields) that no entry point reaches, with visibility and location, plus the roots used.

Roots are public static void main(String[]) methods and detected test methods (JUnit 4/5, TestNG; disabled tests still count). Reachability follows calls, instantiations, field accesses, field initializers, and overrides (a call through an interface or superclass reaches every override). A type is reported only when neither it nor any of its members is reachable.

IMPORTANT: results mean "unreachable from declared entry points", not "safe to delete" - reflection, dependency injection, and serialization entry points are invisible to the graph.

Options:

  • includeTestRoots: count test methods as entry points (default true)

  • maxResults: cap the reported list (default 100)

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeTestRootsNoTreat test methods as entry points (default true)
maxResultsNoMaximum entries to return (default 100)
Behavior5/5

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

No annotations are provided, so the description fully discloses behavior: how reachability is computed (calls, instantiations, field accesses, etc.), what counts as roots (main methods, test methods), and what the output includes (members with visibility and location). It also clarifies that disabled tests still count as entry points.

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

Conciseness5/5

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

The description is well-structured with clear sections (USAGE, OUTPUT, explanation of roots, IMPORTANT caveats, Options). It is concise yet comprehensive, with every sentence adding necessary information.

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?

Given the tool's complexity, the description is complete: it explains the algorithm, the meaning of results, limitations (invisible entry points), and prerequisites. No output schema is provided, but the description sufficiently covers the output format.

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 description coverage is 100%, so baseline is 3. The description adds value by explaining defaults ('default true' for includeTestRoots, 'default 100' for maxResults) and context for the options, which goes beyond the schema's type descriptions.

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 code unreachable from any entry point, project-wide.' It distinguishes this from sibling tools like 'find_unused_code' by specifying the project-wide scope and entry point focus.

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 explicitly provides usage syntax, outlines options, and gives a critical caveat: results indicate unreachability from declared entry points, not safe-to-delete due to reflection and DI. It also notes the prerequisite 'Requires load_project to be called first.'

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