Skip to main content
Glama
jonmmease

jons-mcp-java

by jonmmease

type_definition

Navigate to Java type definitions by specifying file path and position to locate symbol declarations in your codebase.

Instructions

Navigate to the type definition of 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 'locations' array or 'status'/'message' if initializing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
lineYes
characterYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'type_definition' tool. It uses LSP 'textDocument/typeDefinition' request to find type definitions at a given position in a Java file, formats the locations, and handles initialization status.
    @mcp.tool()
    async def type_definition(
        file_path: str,
        line: int,
        character: int,
    ) -> dict:
        """
        Navigate to the type definition of 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 'locations' 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_TYPE_DEFINITION,
            {
                "textDocument": {"uri": path_to_uri(file_path)},
                "position": {"line": line, "character": character}
            }
        )
    
        return format_locations(response)
  • Import statement that loads the navigation module, thereby registering the @mcp.tool()-decorated 'type_definition' function with the FastMCP server.
    # Import tools to register them
    from jons_mcp_java.tools import navigation, symbols, diagnostics, info  # noqa: E402, F401
  • Helper function used by the type_definition handler (and similar tools) to normalize LSP location responses into a standard {'locations': [...]} format.
    def format_locations(response: dict | list | None) -> dict:
        """
        Normalize LSP Location response to a consistent format.
    
        LSP methods like definition can return:
        - null/None
        - Single Location object
        - Array of Location objects
        - Array of LocationLink objects
    
        This normalizes to: {"locations": [...]}
        """
        if response is None:
            return {"locations": []}
    
        if isinstance(response, dict):
            # Single Location or LocationLink
            return {"locations": [_normalize_location(response)]}
    
        if isinstance(response, list):
            return {"locations": [_normalize_location(loc) for loc in response]}
    
        return {"locations": []}
  • LSP method constant used in the type_definition tool request.
    LSP_TEXT_DOCUMENT_TYPE_DEFINITION = "textDocument/typeDefinition"
  • Lists 'type_definition' in __all__ for easy import of tools package.
    "type_definition",
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool navigates to type definitions and returns a dictionary with locations or status/message, which covers basic behavior. However, it lacks details on error handling, performance, or side effects (e.g., whether it modifies files or requires specific server state), leaving gaps in transparency.

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

Conciseness5/5

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

The description is front-loaded with the core purpose in the first sentence, followed by a structured 'Args' and 'Returns' section that efficiently documents parameters and output. Every sentence adds value without redundancy, making it highly concise and well-organized for quick comprehension.

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 (3 parameters, no annotations, but with an output schema), the description is largely complete. It explains the purpose, parameters, and return structure, and the output schema handles return values. However, it lacks context on when to use versus siblings and behavioral details like error cases, slightly reducing completeness.

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 beyond the input schema, which has 0% coverage. It explains that 'file_path' is an absolute path to a Java file, 'line' is a 0-indexed line number, and 'character' is a 0-indexed character position, clarifying usage that isn't evident from the schema alone. This compensates well for the low schema coverage.

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 ('Navigate to the type definition of a symbol') and resource ('a symbol at the given position'), distinguishing it from siblings like 'definition' or 'hover' by focusing on type definitions specifically. The verb 'navigate' implies movement or redirection to the definition location.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance is provided on when to use this tool versus alternatives like 'definition' or 'hover'. The description implies usage for Java files and symbol navigation, but lacks context on prerequisites, exclusions, or comparisons to sibling tools, leaving the agent to infer usage scenarios.

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