Skip to main content
Glama

apply_cleanup

Apply a JDT code clean-up to a Java file and get the rewritten source. Supports converting loops, lambdas, switch expressions, and more.

Instructions

Apply a JDT code clean-up to a file and return the rewritten source.

USAGE: apply_cleanup(filePath="path/to/File.java", cleanupId="convert_loops") OUTPUT: changed flag, a label, and the full rewritten source (the file is NOT written — apply the returned source yourself).

Supported cleanupId values: - convert_loops: rewrite index- and iterator-based for loops as enhanced for loops - convert_to_lambda: convert anonymous classes implementing a functional interface to lambdas - pattern_matching_instanceof: use pattern matching for instanceof checks followed by a cast - convert_to_switch_expression: convert assignment/return switch statements to switch expressions - string_concat_to_text_block: convert multi-line string concatenations to text blocks - do_while_rather_than_while: replace while loops that always run once with do-while loops - invert_equals: invert equals() calls so the constant is the receiver (avoids NPEs) - boolean_value_rather_than_comparison: simplify comparisons with boolean literals (x == true -> x) - else_if: collapse else blocks containing a lone if into else-if chains - overridden_assignment: remove initializers that are overwritten before being read

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to source file
cleanupIdYesClean-up to apply (e.g. 'convert_loops')
Behavior4/5

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

Explicitly states the output format (changed flag, label, full rewritten source) and clarifies that the file is NOT written. This goes beyond the input schema. No annotations are provided, but the description is transparent about the non-destructive nature and output.

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 highly concise and well-structured: a clear purpose statement, a usage example, output description, and an organized list of supported cleanups. Every sentence adds value without redundancy.

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?

Covers the tool's purpose, parameters, valid values, output, and prerequisite. Missing output schema is compensated by describing the output. Could mention error handling or effect on project state, but overall sufficient for an AI agent.

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 coverage is 100% with basic descriptions. The description adds significant value by enumerating all valid cleanupId values with explanations for each, enriching the parameter semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it applies JDT code clean-ups to a file and returns rewritten source. It lists all supported cleanup IDs, distinguishing it from siblings like apply_quick_fix and convert_anonymous_to_lambda. However, it does not explicitly compare to siblings.

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?

Provides a usage example with parameters and a prerequisite ('Requires load_project to be called first'). Does not state when not to use or specify alternatives, but the example and list offer implicit guidance.

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