"""
Godot Domain Tools

Tools for getting Godot engine information.
"""

from godot_mcp.core import create_error_response, godot_server, mcp

__all__ = ["godot_get_version"]


@mcp.tool()
def godot_get_version() -> str:
    """Get the installed Godot version.

    Category: Godot
    """
    try:
        godot_path = godot_server.detect_godot_path()

        godot_server.log_debug("Getting Godot version")
        stdout, stderr = godot_server.run_subprocess(f'"{godot_path}" --version')
        return stdout.strip()
    except Exception as error:
        return create_error_response(
            f"Failed to get Godot version: {error}",
            [
                "Ensure Godot is installed correctly",
                "Check GODOT_PATH environment variable",
            ],
        )
