"""Jira user tools — get user profile."""

from __future__ import annotations

from typing import TYPE_CHECKING, Literal

from a2atlassian.decorators import mcp_tool
from a2atlassian.formatter import OperationResult  # noqa: TC001 — FastMCP needs runtime annotation
from a2atlassian.jira.users import get_user_profile

if TYPE_CHECKING:
    from collections.abc import Callable

    from mcp.server.fastmcp import FastMCP

    from a2atlassian.errors import ErrorEnricher
    from a2atlassian.jira_client import JiraClient


def register_read(
    server: FastMCP,
    get_client: Callable[[str], JiraClient],
    enricher: ErrorEnricher,
) -> None:
    @server.tool()
    @mcp_tool(enricher)
    async def jira_get_user_profile(
        connection: str,
        account_id: str,
        format: Literal["toon", "json"] = "json",  # noqa: A002
    ) -> OperationResult:
        """Get a Jira user profile by account ID."""
        return await get_user_profile(get_client(connection), account_id)
