Skip to main content
Glama

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

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"

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