Skip to main content
Glama
jonmmease

jons-mcp-java

by jonmmease

diagnostics

Identify and report Java code errors and warnings in specific files or across entire projects using Eclipse JDT.LS diagnostics.

Instructions

Get diagnostics (errors, warnings) for a file or all files.

Args: file_path: Optional path to get diagnostics for a specific file. If not provided, returns diagnostics for all files.

Returns: Dictionary with 'diagnostics' array containing formatted diagnostic info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler for the 'diagnostics' MCP tool, decorated with @mcp.tool(). It retrieves diagnostics from the manager for a specific file or all files and formats them.
    @mcp.tool()
    async def diagnostics(
        file_path: str | None = None,
    ) -> dict:
        """
        Get diagnostics (errors, warnings) for a file or all files.
    
        Args:
            file_path: Optional path to get diagnostics for a specific file.
                      If not provided, returns diagnostics for all files.
    
        Returns:
            Dictionary with 'diagnostics' array containing formatted diagnostic info
        """
        manager = get_manager()
        if manager is None:
            return {"status": "error", "message": "Server not initialized"}
    
        if file_path:
            # Get diagnostics for specific file
            raw_diagnostics = manager.get_diagnostics(Path(file_path))
            formatted = _format_diagnostics(file_path, raw_diagnostics)
            return {"diagnostics": formatted}
        else:
            # Get all diagnostics
            all_raw = manager.get_all_diagnostics()
            all_formatted = []
            for uri, diags in all_raw.items():
                try:
                    path = str(uri_to_path(uri))
                except ValueError:
                    path = uri
                all_formatted.extend(_format_diagnostics(path, diags))
    
            return {"diagnostics": all_formatted}
  • Import of the diagnostics tool (along with others) in the FastMCP server, which registers the tools due to the @mcp.tool() decorators.
    # Import tools to register them
    from jons_mcp_java.tools import navigation, symbols, diagnostics, info  # noqa: E402, F401
  • Helper function to format raw LSP diagnostics into a standardized dictionary format used by the tool.
    def _format_diagnostics(file_path: str, diagnostics: list) -> list[dict]:
        """Format LSP diagnostics to a user-friendly format."""
        result = []
        for diag in diagnostics:
            range_obj = diag.get("range", {})
            start = range_obj.get("start", {})
    
            severity = diag.get("severity", 1)
            severity_name = {
                1: "error",
                2: "warning",
                3: "information",
                4: "hint",
            }.get(severity, "unknown")
    
            result.append({
                "file": file_path,
                "line": start.get("line", 0),
                "character": start.get("character", 0),
                "severity": severity_name,
                "message": diag.get("message", ""),
                "source": diag.get("source", "jdtls"),
                "code": diag.get("code"),
            })
    
        return result
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 returns (a dictionary with diagnostics array) and the conditional behavior based on file_path parameter, but doesn't mention important behavioral aspects like whether this is a read-only operation, potential performance implications for 'all files' mode, or error handling for invalid file paths.

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, args, returns) and efficiently communicates essential information in three sentences. Every sentence adds value, though the formatting with separate sections could be slightly more integrated for optimal conciseness.

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 the tool's moderate complexity (single optional parameter), no annotations, but with an output schema present, the description provides adequate context. It explains the parameter behavior and return format, though it could benefit from more behavioral context about the operation's characteristics. The presence of an output schema reduces the need to fully document return values.

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?

The description provides clear semantic meaning for the single parameter beyond what the schema shows (0% coverage). It explains that file_path is optional, what happens when it's provided versus not provided, and the scope implications. Since there's only one parameter and the description fully documents its behavior, this earns a high score despite the low schema coverage.

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 the tool's purpose with a specific verb ('Get') and resource ('diagnostics'), and distinguishes between file-specific and all-files operation. However, it doesn't explicitly differentiate from sibling tools like 'definition' or 'hover' which might also provide file-related information.

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

Usage Guidelines3/5

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

The description implies when to use the tool (to get diagnostic information) and provides basic guidance about the optional file_path parameter, but doesn't explicitly state when to use this versus alternatives like 'workspace_symbols' or 'references' that might provide different types of file information. No explicit exclusions or comparison to siblings is provided.

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/jonmmease/jons-mcp-java'

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