document_symbols
Extract all symbols from a Java file to analyze code structure and enable navigation within Java projects.
Instructions
Get all symbols defined in a Java file.
Args: file_path: Absolute path to the Java file
Returns: Dictionary with 'symbols' array or 'status'/'message' if initializing
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- src/jons_mcp_java/tools/symbols.py:13-49 (handler)Core handler implementation for the 'document_symbols' tool. Decorated with @mcp.tool() for registration. Fetches LSP document symbols for a given Java file path.@mcp.tool() async def document_symbols( file_path: str, ) -> dict: """ Get all symbols defined in a Java file. Args: file_path: Absolute path to the Java file Returns: Dictionary with 'symbols' array 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_DOCUMENT_SYMBOL, { "textDocument": {"uri": path_to_uri(file_path)}, } ) if response is None: return {"symbols": []} # Response is either DocumentSymbol[] or SymbolInformation[] symbols = [format_symbol(sym) for sym in response] return {"symbols": symbols}
- src/jons_mcp_java/tools/__init__.py:9-22 (registration)Imports and exports 'document_symbols' in the tools package __init__.py, facilitating tool discovery and usage in the MCP server.from jons_mcp_java.tools.symbols import document_symbols, workspace_symbols from jons_mcp_java.tools.diagnostics import diagnostics from jons_mcp_java.tools.info import hover __all__ = [ "definition", "references", "implementation", "type_definition", "document_symbols", "workspace_symbols", "diagnostics", "hover", ]