Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
JAVA_PROJECT_PATHNoAuto-load project on startup
JAVA_TOOL_OPTIONSNoJVM options, e.g. -Xmx2g for large projects
JAVALENS_LOG_LEVELNoTRACE/DEBUG/INFO/WARN/ERRORINFO
JAVALENS_TIMEOUT_SECONDSNoOperation timeout30

Capabilities

Features and capabilities supported by this server

CapabilityDetails
tools
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
health_checkA

Check server status and project state.

USAGE: Call on startup to verify server is operational. OUTPUT: Server status, project info if loaded, capabilities.

WORKFLOW:

  1. Call health_check to verify server is running

  2. If no project loaded, call load_project next

  3. Use returned capabilities to understand available features

load_projectA

Load a Java project for analysis. MUST be called before using other analysis tools.

USAGE: load_project(projectPath="/path/to/project") OUTPUT: Project structure summary including packages, source files, build system

Supports:

  • Maven projects (pom.xml)

  • Gradle projects (build.gradle or build.gradle.kts)

  • Plain Java projects with src/ directory

WORKFLOW:

  1. Call load_project with absolute path to project root

  2. Wait for project to load (may take a few seconds for large projects)

  3. Use health_check to verify project is loaded

  4. Begin using analysis tools (search_symbols, find_references, etc.)

SYNC (strict mode): answers are always verified against the files on disk - no reload is needed after editing, adding, or deleting source files. Call load_project only on first use, when a response reports RELOAD_REQUIRED (a build file changed), or to rebuild everything from scratch.

search_symbolsA

Search for types, methods, fields by name pattern. Supports glob patterns: * (any chars), ? (single char)

USAGE: search_symbols(query="*Service", kind="class") OUTPUT: List of matching symbols with locations

EXAMPLES:

  • search_symbols(query="Order*") - classes starting with Order

  • search_symbols(query="*Repository", kind="interface")

  • search_symbols(query="get*", kind="method")

PAGINATION: Use offset parameter for large result sets

IMPORTANT: Requires load_project to be called first.

go_to_definitionA

Navigate to symbol definition.

USAGE: Position cursor on a symbol reference, returns definition location. OUTPUT: File path, line, column of the definition.

IMPORTANT: Uses ZERO-BASED coordinates. If editor shows 'Line 14, Column 5', pass line=13, column=4

Requires load_project to be called first.

find_referencesA

Find all references to a symbol across the project.

USAGE: Position on symbol, find all usages OUTPUT: List of reference locations with context

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

find_implementationsA

Find implementations of an interface or extensions of a class.

USAGE: Position on a type (interface or class), find all implementors/subclasses OUTPUT: List of implementing/extending types with locations

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_type_hierarchyA

Get the type hierarchy (supertypes and subtypes) for a Java type.

USAGE: Position on a type, returns full inheritance chain OUTPUT: Superclasses, interfaces, and all subtypes

Can be called with either:

  • File position (filePath, line, column) - finds type at cursor

  • Type name (typeName) - looks up type by qualified name

IMPORTANT: Uses ZERO-BASED coordinates when using file position.

Requires load_project to be called first.

get_document_symbolsA

Get all symbols (types, methods, fields) in a source file.

USAGE: Provide a file path to get all symbols in that file OUTPUT: Hierarchical list of all types, methods, fields, and nested types

Returns symbols with their locations, kinds, and modifiers.

Requires load_project to be called first.

get_type_membersA

Get all members (methods, fields, nested types) of a specific type.

USAGE: Provide a type name to get all its members OUTPUT: Lists of methods, fields, and nested types with their details

Options:

  • includeInherited: Also include members from superclasses/interfaces

  • memberKind: Filter to "method", "field", or "type" only

Requires load_project to be called first.

get_classpath_infoA

Get project classpath information.

USAGE: Call to get all classpath entries for the loaded project OUTPUT: Source folders, libraries, and classpath containers

Useful for understanding project structure and dependencies.

Requires load_project to be called first.

get_project_structureA

Get project structure showing package hierarchy.

USAGE: Call to see the package tree of the loaded project OUTPUT: Source roots with packages and file counts

Requires load_project to be called first.

get_symbol_infoA

Get detailed information about any symbol at a position.

USAGE: Position on any symbol (type, method, field, variable) OUTPUT: Comprehensive info including kind, modifiers, signature, location

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_type_at_positionA

Get type information at a specific position.

USAGE: Position on a type reference or declaration OUTPUT: Type details including kind, modifiers, superclass, interfaces

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_method_at_positionA

Get method information at a specific position.

USAGE: Position on a method reference or declaration OUTPUT: Method signature, parameters, return type, modifiers, exceptions

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_field_at_positionA

Get field information at a specific position.

USAGE: Position on a field reference or declaration OUTPUT: Field type, modifiers, constant value if applicable

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_hover_infoA

Get hover information (documentation) for a symbol at a position.

USAGE: Position on any symbol OUTPUT: Signature, Javadoc, and quick info similar to IDE hover

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_javadocA

Get parsed Javadoc documentation for a symbol.

USAGE: Position on any documented symbol OUTPUT: Parsed Javadoc with summary, @param, @return, @throws, etc.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_signature_helpA

Get method signature help at a position.

USAGE: Position on a method call or declaration OUTPUT: Method signatures with parameter info

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_enclosing_elementA

Get the enclosing element at a position.

USAGE: Position anywhere in code OUTPUT: Enclosing method, type, and package info

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_super_methodA

Find the method that this method overrides or implements.

USAGE: Position on a method that overrides/implements another OUTPUT: The superclass/interface method being overridden

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_diagnosticsA

Get compilation diagnostics (errors and warnings) for a file or project.

USAGE: get_diagnostics() for all files, or get_diagnostics(filePath="...") for one file OUTPUT: List of compilation errors and warnings with locations

Useful for finding syntax errors, type mismatches, missing imports, etc.

Requires load_project to be called first.

validate_syntaxA

Quick syntax-only validation for a file or inline code.

USAGE: validate_syntax(filePath="...") or validate_syntax(content="...") OUTPUT: Syntax errors (no semantic analysis for speed)

Much faster than get_diagnostics - use for quick syntax checks.

Requires load_project to be called first.

get_call_hierarchy_incomingA

Find all callers of a method (incoming calls).

USAGE: Position cursor on a method name OUTPUT: List of methods that call this method

IMPORTANT: Uses ZERO-BASED coordinates.

Useful for understanding who depends on a method before changing it.

Requires load_project to be called first.

get_call_hierarchy_outgoingA

Find all methods called by a method (outgoing calls).

USAGE: Position cursor on a method name OUTPUT: List of methods that this method calls

IMPORTANT: Uses ZERO-BASED coordinates.

Useful for understanding what a method depends on.

Requires load_project to be called first.

find_field_writesA

Find all write accesses (mutations) to a field.

USAGE: Position cursor on a field declaration or reference OUTPUT: List of locations where the field is modified

IMPORTANT: Uses ZERO-BASED coordinates.

Unlike find_references which returns all usages, this returns only locations where the field value is changed (assignments, increments, etc). Useful for data flow analysis and understanding state mutations.

Requires load_project to be called first.

find_testsA

Find test classes and methods in the project.

USAGE: find_tests() OUTPUT: List of test classes with their test methods

Supports:

  • JUnit 4 (@Test, @Before, @After, etc.)

  • JUnit 5 (@Test, @BeforeEach, @AfterEach, etc.)

  • TestNG annotations

Requires load_project to be called first.

find_unused_codeA

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.

find_unreachable_codeA

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.

find_affected_testsA

Find the test methods that exercise a symbol, directly or transitively.

USAGE: find_affected_tests(filePath="path/to/File.java", line=10, column=5) OUTPUT: Test methods (JUnit 4/5, TestNG) from which the symbol is reachable, with locations - the set of tests to run after changing it.

The caller walk follows calls, instantiations, field accesses, and override declarations (a test calling through an interface or superclass covers the implementation). Non-test intermediate methods are walked through but not reported. Disabled tests are included with disabled=true (they cover the code but will not run). A symbol no test reaches returns an empty set.

Supports project methods, fields, and types as the target symbol.

Options:

  • maxResults: cap the reported list (default 100)

Requires load_project to be called first.

find_possible_bugsA

Find possible bugs and code quality issues.

USAGE: find_possible_bugs() USAGE: find_possible_bugs(filePath="path/to/File.java") OUTPUT: List of potential issues

Detects:

  • Null pointer risks (dereferencing potentially null values)

  • Resource leaks (unclosed streams, connections)

  • Empty catch blocks

  • Comparison issues (== on objects instead of equals)

  • Synchronization issues (sync on String)

Requires load_project to be called first.

rename_symbolA

Rename a symbol (variable, method, field, class, etc.) across the project.

Returns text edits for all occurrences that need to be changed. The caller should apply these edits to perform the rename.

USAGE: Position on symbol, provide new name OUTPUT: List of text edits to apply

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

organize_importsA

Organize imports in a Java file.

Removes unused imports and sorts remaining imports alphabetically. Returns the organized import block that should replace the existing imports.

USAGE: organize_imports(filePath="path/to/File.java") OUTPUT: Organized import statements and list of changes

Requires load_project to be called first.

extract_variableA

Extract an expression at the given position into a local variable.

Returns the text edits needed to extract the expression. The caller should apply these edits to perform the extraction.

USAGE: Select expression by providing start and end positions OUTPUT: Variable declaration and replacement edits

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

extract_methodA

Extract a code block into a new method.

USAGE: Select code range, provide method name OUTPUT: Text edits for method declaration and call site

The tool analyzes the selected code to:

  • Determine which variables become parameters

  • Determine return type based on variables modified

  • Generate appropriate method signature

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

find_annotation_usagesA

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")

Requires load_project to be called first.

find_type_instantiationsA

Find all instantiations of a type (new Foo() calls).

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

USAGE: Provide fully qualified type name OUTPUT: All locations where the type is instantiated with 'new'

Useful for:

  • Understanding object creation patterns

  • Identifying factory method candidates

  • Finding coupling points

Requires load_project to be called first.

find_castsA

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

Requires load_project to be called first.

find_instanceof_checksA

Find all instanceof checks for a type (x instanceof Foo).

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

USAGE: Provide fully qualified type name OUTPUT: All locations where instanceof checks against this type occur

Useful for:

  • Identifying type checking patterns

  • Finding polymorphism opportunities (replace instanceof with virtual dispatch)

  • Understanding type discrimination logic

Requires load_project to be called first.

find_throws_declarationsA

Find all throws declarations of an exception type in method signatures.

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

USAGE: Provide fully qualified exception type name as typeName OUTPUT: All methods that declare 'throws ExceptionType'

Useful for:

  • Understanding exception flow in the codebase

  • Finding all methods that can throw a specific exception

  • Exception handling analysis

Requires load_project to be called first.

find_catch_blocksA

Find all catch blocks for an exception type (catch(ExceptionType e)).

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

USAGE: Provide fully qualified exception type name as typeName OUTPUT: All catch blocks that handle this exception type

Useful for:

  • Understanding exception handling patterns

  • Finding all handlers for a specific exception

  • Exception handling analysis and refactoring

Requires load_project to be called first.

find_method_referencesA

Find all method reference expressions (Foo::bar lambda syntax).

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

USAGE: Position on a method, or provide method details OUTPUT: All locations where the method is used as a method reference

Useful for:

  • Understanding functional programming patterns

  • Finding lambda-style usages of methods

  • Refactoring analysis

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

find_type_argumentsA

Find all usages of a type as a generic type argument (List, Map<K, Foo>).

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

USAGE: Provide fully qualified type name OUTPUT: All locations where the type is used as a generic argument

Useful for:

  • Understanding generic usage patterns

  • Finding all collections/containers of a type

  • API design analysis

Requires load_project to be called first.

analyze_fileA

Comprehensive file analysis in a single call.

USAGE: analyze_file(filePath="path/to/File.java") OUTPUT: File info, imports, types with member counts, diagnostics

Combines:

  • File info (path, package, line count)

  • All imports (with static/on-demand flags)

  • All types with member counts

  • Compilation diagnostics (errors/warnings)

Use this instead of multiple calls to get_document_symbols + get_diagnostics.

Requires load_project to be called first.

analyze_typeA

Comprehensive type analysis in a single call.

USAGE: analyze_type(typeName="com.example.Foo") OUTPUT: Type info, members, hierarchy, usage summary, diagnostics

Combines:

  • Type info (name, kind, modifiers, location)

  • All members (methods, fields, constructors)

  • Type hierarchy (superclass, interfaces, subtypes)

  • Usage summary (instantiations, casts, etc.)

  • Diagnostics for the type's file

Use this instead of multiple calls to get_type_members + get_type_hierarchy + get_type_usage_summary.

Requires load_project to be called first.

analyze_methodA

Comprehensive method analysis in a single call.

USAGE: analyze_method(filePath="path/to/File.java", line=N, column=N) OUTPUT: Method info, parameters, exceptions, callers, callees, override info

Combines:

  • Method info (signature, modifiers, return type)

  • Parameters with types

  • Declared exceptions

  • Incoming calls (who calls this method)

  • Outgoing calls (what this method calls)

  • Override information (super method, overriding methods)

Use this instead of multiple calls to get_method_at_position + call hierarchy tools.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

get_type_usage_summaryA

Get comprehensive usage summary for a type across the codebase.

USAGE: get_type_usage_summary(typeName="com.example.Foo") OUTPUT: Instantiations, casts, instanceof checks, type arguments, annotations

Aggregates all usage patterns in a single call:

  • Instantiations (new Foo())

  • Casts ((Foo) x)

  • Instanceof checks (x instanceof Foo)

  • Type arguments (List)

  • Annotation usages (if annotation type)

Use this to understand how a type is used throughout the project.

Requires load_project to be called first.

extract_constantA

Extract an expression into a static final constant at class level.

Returns the text edits needed to extract the expression. The caller should apply these edits to perform the extraction.

USAGE: Select expression by providing start and end positions OUTPUT: Constant declaration and replacement edits

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

inline_variableA

Inline a local variable by replacing all usages with its initializer expression.

Returns the text edits needed to inline the variable. The caller should apply these edits to perform the inlining.

USAGE: Position cursor on variable declaration or usage OUTPUT: Edits to delete declaration and replace usages with initializer

IMPORTANT: Uses ZERO-BASED coordinates. SAFETY: Will refuse if variable is modified after initialization.

Requires load_project to be called first.

inline_methodA

Inline a method call by replacing it with the method body.

Returns the text edit needed to inline the method call. The caller should apply this edit to perform the inlining.

USAGE: Position cursor on a method call OUTPUT: Edit to replace call with method body

IMPORTANT: Uses ZERO-BASED coordinates.

LIMITATIONS:

  • Method must be in the same project (source available)

  • Works best with simple methods (no complex control flow)

  • Single return statement is handled, multiple returns may need review

Requires load_project to be called first.

change_method_signatureA

Change method signature (parameters, return type, or name) and update all call sites.

Returns text edits for the method declaration and all call sites. The caller should apply these edits to perform the change.

USAGE: Position on method declaration, provide changes OUTPUT: Edits for declaration and all call sites

PARAMETER OPERATIONS:

  • Add new parameter with default value for existing calls

  • Remove parameter (will remove from calls)

  • Rename parameter

  • Reorder parameters (specify all parameters in new order)

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

extract_interfaceA

Extract an interface from a class containing selected public methods.

Returns the text for a new interface file and edits to add 'implements' clause to the original class.

USAGE: Position on class, provide interface name, optionally specify methods OUTPUT: Interface file content and class modification edit

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

convert_anonymous_to_lambdaA

Convert an anonymous class implementing a functional interface to a lambda expression.

Returns the text edit needed to convert the anonymous class to a lambda. The caller should apply this edit to perform the conversion.

USAGE: Position cursor on the 'new' keyword of the anonymous class OUTPUT: Edit to replace anonymous class with lambda

IMPORTANT: Uses ZERO-BASED coordinates. REQUIREMENTS: The anonymous class must implement a functional interface (exactly one abstract method).

Requires load_project to be called first.

suggest_importsA

Find import candidates for unresolved type.

USAGE: suggest_imports(typeName="List") OUTPUT: List of matching types with fully qualified names and relevance

Searches project sources, JDK, and libraries for types matching the simple name. Results are sorted by relevance (java.util types ranked higher than java.awt, etc.).

Requires load_project to be called first.

get_quick_fixesA

List available fixes for a problem at position.

USAGE: get_quick_fixes(filePath="...", line=10) OUTPUT: List of quick fixes with fixId, label, and category

Supported fixes:

  • UndefinedType: Suggest imports for unresolved types

  • UnusedImport: Remove unused import

  • UnhandledException: Add throws or surround with try-catch

IMPORTANT: Uses ZERO-BASED line numbers.

Requires load_project to be called first.

apply_quick_fixA

Apply a fix by ID.

USAGE: apply_quick_fix(filePath="...", fixId="add_import:java.util.List") OUTPUT: Text edits to apply the fix

Fix ID formats:

  • add_import:{fullyQualifiedName} - Add an import statement

  • remove_import:{index} - Remove import at index

  • add_throws:{exceptionType} - Add throws declaration to method

  • surround_try_catch:{exceptionType} - Wrap statement in try-catch

IMPORTANT: Uses ZERO-BASED line numbers.

Requires load_project to be called first.

apply_cleanupA

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.

encapsulate_fieldA

Encapsulate a field: generate a getter/setter pair and rewrite all direct accesses (in this and other files) to go through them.

USAGE: Position on the field name; optionally name the accessors. OUTPUT: editsByFile with all required text edits; warnings from JDT's own condition checking. Edits are returned as text - apply them yourself.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

pull_upA

Pull a method or field up into the superclass and remove it from the declaring subclass.

USAGE: Position on the member name in the subclass. OUTPUT: editsByFile covering the superclass (member added) and the subclass (member removed); warnings from JDT's condition checking. Edits are returned as text - apply them yourself.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

push_downA

Push a method or field down into the declaring class's subclasses and remove it from the declaring class.

USAGE: Position on the member name in the superclass. OUTPUT: editsByFile covering the superclass (member removed) and each subclass (member added); warnings from JDT's condition checking. Edits are returned as text - apply them yourself.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

extract_superclassA

Extract a new superclass from a class: the member at the position moves up into a newly created superclass, and the class extends it.

USAGE: Position on the member to extract; provide the new superclass name. OUTPUT: createdFiles carries the new superclass file content; editsByFile carries the source class's edits. Nothing is written - create the file and apply the edits yourself.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

introduce_parameter_objectA

Bundle a method's parameters into a new parameter-object class and rewrite the method and all callers to use it. The class is generated as a member of the declaring type.

USAGE: Position on the method name; optionally name the class and parameter. OUTPUT: editsByFile with all required edits; warnings from JDT's condition checking. Edits are returned as text - apply them yourself.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

move_type_to_new_fileA

Move a member (nested) type into its own top-level file. Non-static member types gain a field referencing the former enclosing instance.

USAGE: Position on the nested type's name. OUTPUT: createdFiles carries the new top-level file content; editsByFile carries the enclosing file's edits. Nothing is written - create the file and apply the edits yourself.

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

diagnose_and_fixA

Diagnose a file and compute the quick-fix edits in one call: runs diagnostics, resolves the available fixes per fixable problem, and returns the top fix's edits for each, combined as editsByFile.

USAGE: diagnose_and_fix(filePath="path/to/File.java") OUTPUT: problems (each with its chosen fix when one exists) and editsByFile with the computed edits. NOTHING is written - apply the returned edits yourself.

A file with no fixable diagnostics returns empty problems/edits.

Requires load_project to be called first.

get_complexity_metricsA

Get cyclomatic complexity, cognitive complexity, LOC.

USAGE: get_complexity_metrics(filePath="path/to/File.java") OUTPUT: Complexity metrics with risk assessment

Metrics:

  • Cyclomatic Complexity: Count of decision points (+1 for if/for/while/case/catch)

  • Cognitive Complexity: Penalizes nesting and breaks in linear flow

  • LOC: Physical and logical lines of code

Risk levels:

  • High: CC > 10

  • Medium: CC 6-10

  • Low: CC <= 5

Requires load_project to be called first.

get_dependency_graphA

Get package/type dependencies.

USAGE: get_dependency_graph(scope="type", name="com.example.OrderService") USAGE: get_dependency_graph(scope="package", name="com.example.service") OUTPUT: Dependency graph with nodes and edges

Dependency types tracked:

  • import: Direct imports

  • extends: Superclass inheritance

  • implements: Interface implementation

  • field: Field type dependencies

  • parameter: Method parameter types

  • return: Method return types

Requires load_project to be called first.

find_circular_dependenciesA

Detect cycles in packages.

USAGE: find_circular_dependencies() USAGE: find_circular_dependencies(packageFilter="com.example") OUTPUT: List of circular dependency cycles

Uses Tarjan's SCC algorithm to efficiently detect all cycles. Reports cycle paths and affected packages.

Requires load_project to be called first.

analyze_change_impactA

Analyze the blast radius of changing a symbol.

USAGE: analyze_change_impact(filePath="path/to/File.java", line=10, column=5) OUTPUT: All files and call sites affected, grouped by file

Options:

  • depth: How many levels of callers to follow (default 1, max 3) depth=1: direct references only depth=2: references + callers of those references depth=3: three levels deep

  • transitive: full reverse closure over the project call graph (default false). No depth ceiling; follows calls, instantiations, field accesses, and override declarations (callers through an interface or superclass count). Returns affectedMethods + affectedFiles instead of callSites. Supports project methods, fields, and types.

  • maxResults: cap on affectedMethods in transitive mode (default 200)

Requires load_project to be called first.

analyze_control_flowB

Analyze the control flow structure of a method.

USAGE: analyze_control_flow(filePath="path/to/File.java", line=10, column=5) OUTPUT: Branching points, loops, returns, throws, and nesting depth

Reports:

  • Branch count (if/switch/ternary)

  • Loop count and types (for/while/do-while/enhanced-for)

  • Return points with line numbers

  • Throw points with exception types and line numbers

  • Try-catch blocks with caught exception types

  • Maximum nesting depth

Requires load_project to be called first.

analyze_data_flowA

Analyze data flow within a method.

USAGE: analyze_data_flow(filePath="path/to/File.java", line=10, column=5) OUTPUT: Variables with read/write/declaration info

Reports for each variable:

  • name and type

  • whether it is declared, read, written

  • whether it is a parameter, local variable, or field

  • return statement count and types

Useful for understanding side effects before extracting methods.

Options:

  • followCalls: opt-in interprocedural mode (default false). Tracks two fact kinds across argument-to-parameter hops into project callees and reports interproceduralFlows:

    • null facts - locals assigned null; sink = a dereference of the tracked value in a callee (potential NPE)

    • taint facts - this method's parameters, propagated through aliases and expressions; sink = the value escaping into a non-project (binary) callee May-analysis: reassignments do not kill facts. Returned values are not tracked back into callers.

  • maxCallDepth: call-edge bound for followCalls (default 2)

Requires load_project to be called first.

get_di_registrationsA

Find all dependency injection registrations in the project.

USAGE: get_di_registrations() OUTPUT: Components, configurations, beans, and injection points

Scans for:

  • Spring components: @Component, @Service, @Repository, @Controller, @RestController

  • Configuration: @Configuration

  • Bean definitions: @Bean

  • Injection points: @Autowired, @Inject (javax and jakarta)

Returns empty categories for non-Spring projects (does not error).

Requires load_project to be called first.

get_jpa_modelA

Assemble the project's JPA entity model.

USAGE: get_jpa_model() OUTPUT: Entities with table name, id field, and relationships (kind, target entity, mappedBy side), with locations.

Scans @Entity types (jakarta.persistence and javax.persistence) and reads @Table, @Id, and @OneToMany/@ManyToOne/@OneToOne/ @ManyToMany field annotations. Relationship targets are resolved from the field's type binding, including through collection type arguments (List -> Order).

Projects without JPA on the classpath return an empty model.

Options:

  • maxResults: cap the reported entities (default 100)

Requires load_project to be called first.

get_http_endpointsA

Assemble the project's HTTP route table.

USAGE: get_http_endpoints() OUTPUT: route -> handler entries (HTTP method, effective path, handler method, framework, location), sorted by path.

Supports:

  • Spring verb shortcuts: @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping; the class-level @RequestMapping value is composed as the path prefix.

  • JAX-RS (jakarta.ws.rs and javax.ws.rs): @GET/@POST/... verbs with class-level and method-level @Path composed.

Method-level @RequestMapping(method=...) routes are not assembled; verb-shortcut annotations are the supported Spring form.

Projects without these frameworks return an empty table.

Options:

  • maxResults: cap the reported endpoints (default 200)

Requires load_project to be called first.

find_reflection_usageA

Find places where Java reflection API is used.

USAGE: find_reflection_usage() OUTPUT: All reflection calls grouped by method type

Detects calls to:

  • Class.forName(), Class.newInstance()

  • Class.getMethod/getDeclaredMethod/getField/getDeclaredField

  • Class.getConstructor/getDeclaredConstructor

  • Method.invoke(), Field.get/set(), Constructor.newInstance()

These usages are invisible to static reference searches and can break when types or methods are renamed.

Requires load_project to be called first.

find_large_classesA

Find classes that exceed size thresholds.

USAGE: find_large_classes(maxMethods=20, maxFields=10, maxLines=300) OUTPUT: List of classes exceeding any threshold with their metrics

Default thresholds:

  • maxMethods: 20 methods

  • maxFields: 10 fields

  • maxLines: 300 lines

Requires load_project to be called first.

find_naming_violationsA

Check code against standard Java naming conventions.

USAGE: find_naming_violations(filePath="path/to/File.java") OUTPUT: List of naming convention violations

Conventions checked:

  • Classes/interfaces/enums: PascalCase

  • Methods: camelCase

  • Fields: camelCase

  • Constants (static final): UPPER_SNAKE_CASE

  • Parameters: camelCase

If filePath is omitted, scans all project files.

Requires load_project to be called first.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

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