type_definition
Navigate to type definitions in Java code by specifying file path and position to jump directly to symbol declarations.
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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| line | Yes | ||
| character | Yes |
Implementation Reference
- The 'type_definition' tool handler: sends LSP 'textDocument/typeDefinition' request for the symbol at the given position in a Java file, formats locations, handles server 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)
- src/jons_mcp_java/tools/__init__.py:3-8 (registration)Imports the type_definition tool from navigation.py into the tools package __init__, enabling registration when the package is imported.from jons_mcp_java.tools.navigation import ( definition, implementation, references, type_definition, )
- src/jons_mcp_java/constants.py:14-14 (helper)LSP constant for the 'textDocument/typeDefinition' method used in the type_definition tool request.LSP_TEXT_DOCUMENT_TYPE_DEFINITION = "textDocument/typeDefinition"
- Import of the LSP type definition constant in the navigation tools module.LSP_TEXT_DOCUMENT_TYPE_DEFINITION,