// {{ 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.

use {{ crate_name }}::core::config_manager::load_config;

struct VersionRow {
    label: &'static str,
    is_default: bool,
}

// mcpify:versions:begin
const KNOWN_VERSIONS: &[VersionRow] = &[
{%- for v in version_entries %}
    VersionRow {
        label: "{{ v.label }}",
        is_default: {{ v.label == default_version_label }},
    },
{%- endfor %}
];
// mcpify:versions:end

pub fn run() -> anyhow::Result<()> {
    let active_version = load_config(serde_json::Map::new())
        .map(|config| config.api_version)
        .unwrap_or_default();

    for row in KNOWN_VERSIONS {
        let mut markers = Vec::new();
        if row.is_default {
            markers.push("default");
        }
        if row.label == active_version {
            markers.push("active");
        }
        if markers.is_empty() {
            println!("{}", row.label);
        } else {
            println!("{} ({})", row.label, markers.join(", "));
        }
    }
    Ok(())
}
