Skip to main content
Glama
jonmmease

jons-mcp-java

by jonmmease

document_symbols

Extract all symbols from a Java file to enable code navigation and analysis. This tool identifies classes, methods, and variables within Java source code for development workflows.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function implementing the 'document_symbols' tool logic. It uses the JDT.LS client manager to get the appropriate LSP client, sends a documentSymbol request, formats the response, and returns the symbols.
    @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}
  • Import statement in the main server file that loads the symbols module, thereby registering the 'document_symbols' tool via FastMCP's decorator system (@mcp.tool()).
    from jons_mcp_java.tools import navigation, symbols, diagnostics, info  # noqa: E402, F401
  • The 'document_symbols' tool is listed in the __all__ export list of the tools package, facilitating its import and registration.
    "document_symbols",
  • Imports helper functions used in the document_symbols handler: format_symbol to process LSP symbols and path_to_uri for URI conversion.
    from jons_mcp_java.utils import format_symbol, path_to_uri
Behavior2/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 mentions the return structure ('Dictionary with symbols array or status/message'), which adds some behavioral context beyond the input schema. However, it does not disclose critical traits like whether this is a read-only operation, potential errors (e.g., file not found), performance implications, or initialization requirements. The description adds minimal value beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The 'Args' and 'Returns' sections are structured clearly, though slightly redundant given the output schema exists. Every sentence adds value, but minor trimming could improve efficiency.

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 (single parameter, no annotations, but with an output schema), the description is reasonably complete. It covers purpose, parameter semantics, and return structure, and the output schema reduces the need to detail return values. However, it lacks behavioral details like error handling or performance, leaving some gaps for a tool interacting with file systems.

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?

The description adds meaningful context for the single parameter 'file_path' by specifying it must be an 'Absolute path to the Java file', which clarifies usage beyond the schema's type-only definition (string). With 0% schema description coverage and only one parameter, this compensates adequately, 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 specific action ('Get all symbols defined') and resource ('in a Java file'), distinguishing it from sibling tools like 'workspace_symbols' (which likely searches across multiple files) or 'definition' (which likely finds a specific symbol's definition). The verb 'Get' combined with the resource scope makes the purpose unambiguous.

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 specifying 'Java file' and 'Absolute path', but does not explicitly state when to use this tool versus alternatives like 'workspace_symbols' (for broader searches) or 'definition' (for specific symbol details). It provides basic prerequisites (file path) but lacks explicit guidance on tool selection among siblings.

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