import requests


def get_server_version(endpoint: str = "http://localhost") -> dict:
    """Function to fetch the discover endpoint from the local server

    Args:
        endpoint: The server root endpoint, including the protocol without a trailing slash.

    Returns:
        a dict with the version and build hash
    """
    resp = requests.get(f"{endpoint}/core/v1/discover")
    if resp.status_code != 200:
        raise Exception("Failed to load version information from server")

    data = resp.json()

    return {"version": data['version'], "build": data['build']}