Skip to main content
Glama

hover

Retrieve Java documentation and type information for symbols at specific positions in files 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 core handler for the 'hover' MCP tool. It uses the JDT.LS client to send an LSP 'textDocument/hover' request for the given position in a Java file and processes the response contents into a markdown-formatted 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}
  • Import of tool modules (including info.py containing hover) after FastMCP server creation, which registers all @mcp.tool()-decorated functions as MCP tools.
    from jons_mcp_java.tools import navigation, symbols, diagnostics, info # noqa: E402, F401
  • LSP method constant used in the hover tool's LSP request.
    LSP_TEXT_DOCUMENT_HOVER = "textDocument/hover"
  • Explicit import of the hover function to expose it via tools.__init__ for the server registration import.
    from jons_mcp_java.tools.info import hover
  • Client LSP capabilities declaration requesting hover support with markdown/plaintext content format from JDT.LS.
    "hover": {"contentFormat": ["markdown", "plaintext"]},

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