# MCP Server Configuration - Nickel Format
# Auto-generated by provisioning TypeDialog
# Edit via: nu provisioning/.typedialog/provisioning/platform/scripts/configure.nu mcp-server {mode}

let mcp_server_schema = import "../schemas/mcp-server.ncl" in

{
  mcp_server | mcp_server_schema.MCPServerConfig = {
    # Workspace Configuration
    workspace = {
      {%- if workspace_name %}
      name = "{{ workspace_name }}",
      {%- endif %}
      {%- if workspace_path %}
      path = "{{ workspace_path }}",
      {%- endif %}
      {%- if workspace_enabled is defined %}
      enabled = {{ workspace_enabled | lower }},
      {%- endif %}
      {%- if multi_workspace_mode is defined %}
      multi_workspace = {{ multi_workspace_mode | lower }},
      {%- endif %}
    },

    # HTTP Server Configuration
    server = {
      {%- if server_host %}
      host = "{{ server_host }}",
      {%- endif %}
      {%- if server_port %}
      port = {{ server_port }},
      {%- endif %}
      {%- if server_workers %}
      workers = {{ server_workers }},
      {%- endif %}
      {%- if server_keep_alive %}
      keep_alive = {{ server_keep_alive }},
      {%- endif %}
      {%- if server_max_connections %}
      max_connections = {{ server_max_connections }},
      {%- endif %}
      {%- if server_request_timeout %}
      request_timeout = {{ server_request_timeout }},
      {%- endif %}
    },

    # MCP Protocol Configuration
    protocol = {
      {%- if protocol_version %}
      version = "{{ protocol_version }}",
      {%- endif %}
      {%- if transport_endpoint %}
      transport = {
        {%- if transport_endpoint %}
        endpoint = "{{ transport_endpoint }}",
        {%- endif %}
        {%- if transport_timeout %}
        timeout = {{ transport_timeout }},
        {%- endif %}
      },
      {%- endif %}
    },

    # Tools Configuration
    tools = {
      {%- if tools_enabled is defined %}
      enabled = {{ tools_enabled | lower }},
      {%- endif %}
      {%- if tools_max_concurrent %}
      max_concurrent = {{ tools_max_concurrent }},
      {%- endif %}
      {%- if tools_timeout %}
      timeout = {{ tools_timeout }},
      {%- endif %}
      {%- if tools_validation_enabled is defined %}
      validation = {
        enabled = {{ tools_validation_enabled | lower }},
        {%- if tools_validation_strict is defined %}
        strict_mode = {{ tools_validation_strict | lower }},
        {%- endif %}
      },
      {%- endif %}
      {%- if tools_cache_enabled is defined %}
      cache = {
        enabled = {{ tools_cache_enabled | lower }},
        {%- if tools_cache_ttl %}
        ttl = {{ tools_cache_ttl }},
        {%- endif %}
      },
      {%- endif %}
    },

    # Prompts Configuration
    prompts = {
      {%- if prompts_enabled is defined %}
      enabled = {{ prompts_enabled | lower }},
      {%- endif %}
      {%- if prompts_max_templates %}
      max_templates = {{ prompts_max_templates }},
      {%- endif %}
      {%- if prompts_cache_enabled is defined %}
      cache = {
        enabled = {{ prompts_cache_enabled | lower }},
        {%- if prompts_cache_ttl %}
        ttl = {{ prompts_cache_ttl }},
        {%- endif %}
      },
      {%- endif %}
      {%- if prompts_versioning_enabled is defined %}
      versioning = {
        enabled = {{ prompts_versioning_enabled | lower }},
        {%- if prompts_versioning_max_versions %}
        max_versions = {{ prompts_versioning_max_versions }},
        {%- endif %}
      },
      {%- endif %}
    },

    # Resources Configuration
    resources = {
      {%- if resources_enabled is defined %}
      enabled = {{ resources_enabled | lower }},
      {%- endif %}
      {%- if resources_max_size %}
      max_size = {{ resources_max_size }},
      {%- endif %}
      {%- if resources_cache_enabled is defined %}
      cache = {
        enabled = {{ resources_cache_enabled | lower }},
        {%- if resources_cache_max_size_mb %}
        max_size_mb = {{ resources_cache_max_size_mb }},
        {%- endif %}
        {%- if resources_cache_ttl %}
        ttl = {{ resources_cache_ttl }},
        {%- endif %}
      },
      {%- endif %}
      {%- if resources_validation_enabled is defined %}
      validation = {
        enabled = {{ resources_validation_enabled | lower }},
        {%- if resources_validation_max_depth %}
        max_depth = {{ resources_validation_max_depth }},
        {%- endif %}
      },
      {%- endif %}
    },

    # Sampling Configuration
    sampling = {
      {%- if sampling_enabled is defined %}
      enabled = {{ sampling_enabled | lower }},
      {%- endif %}
      {%- if sampling_max_tokens %}
      max_tokens = {{ sampling_max_tokens }},
      {%- endif %}
      {%- if sampling_model %}
      model = "{{ sampling_model }}",
      {%- endif %}
      {%- if sampling_temperature %}
      temperature = {{ sampling_temperature }},
      {%- endif %}
      {%- if sampling_cache_enabled is defined %}
      cache = {
        enabled = {{ sampling_cache_enabled | lower }},
        {%- if sampling_cache_ttl %}
        ttl = {{ sampling_cache_ttl }},
        {%- endif %}
      },
      {%- endif %}
    },

    # Monitoring Configuration (optional)
    {%- if monitoring_enabled is defined %}
    monitoring = {
      enabled = {{ monitoring_enabled | lower }},
    },
    {%- endif %}

    # Logging Configuration (optional)
    {%- if logging_level %}
    logging = {
      level = "{{ logging_level }}",
      {%- if logging_format %}
      format = "{{ logging_format }}",
      {%- endif %}
    },
    {%- endif %}
  },
}
