Skip to main content
Glama
jonmmease

jons-mcp-java

by jonmmease

hover

Retrieve Javadoc and type information for Java symbols by specifying file path and position to understand code functionality during development.

Instructions

Get hover information (Javadoc, type info) for a symbol at the given position.

Args: file_path: Absolute path to the Java file line: 0-indexed line number character: 0-indexed character position

Returns: Dictionary with 'content' (markdown) or 'status'/'message' if initializing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
lineYes
characterYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler for the 'hover' tool. It is decorated with @mcp.tool(), which both defines and registers the tool in the MCP server. The function sends an LSP 'textDocument/hover' request to the JDTLS language server for the specified position in a Java file and formats the response contents into a markdown string.
    @mcp.tool()
    async def hover(
        file_path: str,
        line: int,
        character: int,
    ) -> dict:
        """
        Get hover information (Javadoc, type info) for a symbol at the given position.
    
        Args:
            file_path: Absolute path to the Java file
            line: 0-indexed line number
            character: 0-indexed character position
    
        Returns:
            Dictionary with 'content' (markdown) or 'status'/'message' if initializing
        """
        manager = get_manager()
        if manager is None:
            return {"status": "error", "message": "Server not initialized"}
    
        client, status = await manager.get_client_for_file_with_status(Path(file_path))
    
        if client is None:
            return {"status": "initializing", "message": status}
    
        await client.ensure_file_open(file_path)
    
        response = await client.request(
            LSP_TEXT_DOCUMENT_HOVER,
            {
                "textDocument": {"uri": path_to_uri(file_path)},
                "position": {"line": line, "character": character}
            }
        )
    
        if response is None:
            return {"content": None, "message": "No hover information available"}
    
        # Extract content from hover response
        contents = response.get("contents", {})
    
        if isinstance(contents, str):
            return {"content": contents}
    
        if isinstance(contents, dict):
            # MarkupContent
            return {"content": contents.get("value", "")}
    
        if isinstance(contents, list):
            # Array of MarkedString or MarkupContent
            parts = []
            for item in contents:
                if isinstance(item, str):
                    parts.append(item)
                elif isinstance(item, dict):
                    if "value" in item:
                        parts.append(item["value"])
                    elif "language" in item:
                        # MarkedString with language
                        lang = item.get("language", "")
                        value = item.get("value", "")
                        parts.append(f"```{lang}\n{value}\n```")
            return {"content": "\n\n".join(parts)}
    
        return {"content": None}
  • The import statement in the MCP server lifespan that loads the tools modules, triggering the registration of the 'hover' tool (located in the 'info' module) via its @mcp.tool() decorator.
    # Import tools to register them
    from jons_mcp_java.tools import navigation, symbols, diagnostics, info  # noqa: E402, F401
  • Constant defining the LSP method name used exclusively by the hover tool to request hover information from the JDTLS server.
    LSP_TEXT_DOCUMENT_HOVER = "textDocument/hover"
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool retrieves information (implying read-only behavior) and mentions return values with 'content' or 'status'/'message', but lacks details on permissions, rate limits, or error handling. It adds some context but is not comprehensive for behavioral traits.

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 appropriately sized and front-loaded, starting with the core purpose, followed by structured 'Args' and 'Returns' sections. Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse.

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 (3 parameters, no annotations, but has output schema), the description is fairly complete. It covers purpose, parameters, and return values, and the output schema handles return details. However, it lacks guidance on usage versus siblings and could include more behavioral context like initialization status.

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 0%, so the description must compensate. It provides clear semantics for all three parameters (file_path, line, character) in the 'Args' section, explaining they specify the Java file and 0-indexed position. This adds meaningful context beyond the bare schema, though it could include format examples or constraints.

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 with specific verb ('Get') and resource ('hover information'), specifying it retrieves Javadoc or type info for a symbol at a given position. It distinguishes from siblings by focusing on hover details rather than definitions, diagnostics, or other symbol-related operations.

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 usage context by mentioning 'Javadoc, type info' and 'symbol at the given position', suggesting it's for code analysis in Java files. However, it does not explicitly state when to use this tool versus alternatives like 'definition' or 'type_definition', nor provide exclusions or prerequisites.

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