Skip to main content
Glama

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
NameRequiredDescriptionDefault
file_pathYes

Implementation Reference

  • 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}
  • 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", ]

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