"""{{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

v8 multi-version support: lists the OpenAPI spec versions this project
currently has a store for (added at `generate`/`mcpify add-version` time),
showing which is the default/latest and which is active for this process.
"""

from __future__ import annotations

from dataclasses import dataclass

from ..core.config import load_config


@dataclass
class VersionRow:
    label: str
    is_default: bool


# mcpify:versions:begin
KNOWN_VERSIONS: list[VersionRow] = [
{%- for v in version_entries %}
    VersionRow(label="{{ v.label }}", is_default={% if v.label == default_version_label %}True{% else %}False{% endif %}),
{%- endfor %}
]
# mcpify:versions:end


def run() -> None:
    try:
        active_version = load_config().api_version
    except Exception:  # config not yet set up — still show what's available
        active_version = ""

    for row in KNOWN_VERSIONS:
        markers = [marker for marker in [
            "default" if row.is_default else None,
            "active" if row.label == active_version else None,
        ] if marker]
        if markers:
            print(f"{row.label} ({', '.join(markers)})")
        else:
            print(row.label)
