# MCP Server Configuration - TOML Export
# Generates TOML configuration for Model Context Protocol (MCP) server
# Supports 4 deployment modes: solo, multiuser, cicd, enterprise
#
# Usage:
#   nickel export --format toml mcp-server-config.toml.ncl > mcp-server.toml

{
  # Server Configuration
  server = {
    host = "0.0.0.0",
    port = 8888,

    # Protocol: "stdio" (process-based) or "http" (network-based)
    protocol = "stdio",

    workers = 4,
    keep_alive = 75,
  },

  # MCP Capabilities Configuration
  capabilities = {
    # Tools: functions available to Claude and other LLMs
    tools = {
      enabled = true,
      max_concurrent = 10,
      timeout = 30000,  # milliseconds
      categories = [
        "orchestrator",
        "provisioning",
        "workspace",
        "configuration",
        "system",
      ],
    },

    # Resources: files, databases, external systems
    resources = {
      enabled = true,
      max_size = 1073741824,  # 1GB in bytes
      caching = {
        enabled = true,
        ttl = 3600,  # seconds (1 hour)
        max_entries = 1000,
      },
    },

    # Prompts: predefined prompts for Claude
    prompts = {
      enabled = true,
      max_length = 10000,
      template_engine = "jinja2",
    },

    # Sampling: model configuration for LLM calls
    sampling = {
      enabled = false,
      models = ["claude-3-opus", "claude-3-sonnet"],
      default_model = "claude-3-opus",
      temperature = 0.7,
      max_tokens = 4096,
    },
  },

  # Tool Configuration
  tools = {
    # Orchestrator tools
    orchestrator = {
      enabled = true,
      submit_workflow = {
        description = "Submit a workflow to the orchestrator",
        timeout = 60000,
      },
      list_workflows = {
        description = "List all workflows",
        timeout = 10000,
      },
      get_workflow = {
        description = "Get workflow details",
        timeout = 10000,
      },
      cancel_workflow = {
        description = "Cancel a running workflow",
        timeout = 30000,
      },
    },

    # Provisioning tools
    provisioning = {
      enabled = true,
      deploy_infrastructure = {
        description = "Deploy infrastructure",
        timeout = 300000,
      },
      validate_config = {
        description = "Validate provisioning configuration",
        timeout = 30000,
      },
      list_deployments = {
        description = "List deployments",
        timeout = 10000,
      },
    },

    # Workspace tools
    workspace = {
      enabled = true,
      list_workspaces = {
        description = "List workspaces",
        timeout = 10000,
      },
      create_workspace = {
        description = "Create a new workspace",
        timeout = 60000,
      },
      delete_workspace = {
        description = "Delete a workspace",
        timeout = 60000,
      },
    },
  },

  # Resource Configuration
  resources = {
    # File system resources
    file_system = {
      enabled = true,
      root_path = "/var/lib/provisioning",
      allow_write = false,
      allowed_extensions = ["ncl", "toml", "yaml", "json", "txt"],
      max_file_size = 10485760,  # 10MB in bytes
    },

    # Database resources
    database = {
      enabled = true,
      connections = {
        orchestrator = {
          type = "http",
          url = "http://orchestrator:9090/api",
        },
        control_center = {
          type = "http",
          url = "http://control-center:8080/api",
        },
      },
    },

    # External API resources
    external_apis = {
      enabled = true,
      allowed_domains = [
        "orchestrator:9090",
        "control-center:8080",
        "api.example.com",
      ],
    },
  },

  # Prompt Configuration
  prompts = {
    # System prompts available to Claude
    system_prompts = {
      infrastructure_expert = {
        name = "Infrastructure Expert",
        description = "Expert in provisioning and infrastructure management",
        content = "You are an expert in cloud infrastructure and provisioning systems.",
      },
      workflow_assistant = {
        name = "Workflow Assistant",
        description = "Assistant for orchestrating workflows",
        content = "You are an assistant for managing and orchestrating workflows.",
      },
    },

    # User prompts
    user_prompts = {
      enabled = true,
      max_custom = 50,  # Maximum custom user prompts
    },
  },

  # Integration Configuration
  integration = {
    # Orchestrator integration
    orchestrator = {
      enabled = true,
      url = "http://orchestrator:9090",
      timeout = 30,  # seconds
      auth = {
        method = "jwt",
        token = "${ORCHESTRATOR_TOKEN}",
      },
    },

    # Control Center integration
    control_center = {
      enabled = true,
      url = "http://control-center:8080",
      timeout = 30,
      auth = {
        method = "jwt",
        token = "${CONTROL_CENTER_TOKEN}",
      },
    },

    # Claude integration
    claude = {
      enabled = true,
      api_key = "${CLAUDE_API_KEY}",
      model = "claude-3-opus-20240229",
      max_tokens = 4096,
    },
  },

  # Security Configuration
  security = {
    # Authentication
    auth = {
      enabled = true,
      method = "jwt",
      jwt_secret = "${JWT_SECRET}",
    },

    # Authorization
    authorization = {
      enabled = true,
      role_based = true,
      default_role = "viewer",
    },

    # Rate limiting
    rate_limit = {
      enabled = true,
      requests_per_second = 100,
      burst_size = 20,
    },

    # Input validation
    input_validation = {
      enabled = true,
      max_input_size = 1000000,  # 1MB
      sanitize_inputs = true,
    },
  },

  # Monitoring and Observability
  monitoring = {
    enabled = true,

    # Metrics
    metrics = {
      enabled = true,
      interval = 30,
      export_format = "prometheus",
    },

    # Health checks
    health_check = {
      enabled = true,
      interval = 30,
      timeout = 10,
    },

    # Audit logging
    audit = {
      enabled = true,
      log_all_requests = true,
      log_sensitive_data = false,
      retention_days = 90,
    },

    # Error tracking
    error_tracking = {
      enabled = true,
      sample_rate = 1.0,
    },
  },

  # Logging Configuration
  logging = {
    level = "info",
    format = "json",
    outputs = [
      {
        destination = "stdout",
        level = "info",
      },
      {
        destination = "file",
        path = "/var/log/provisioning/mcp-server/mcp-server.log",
        level = "debug",
        rotation = {
          max_size = "100MB",
          max_backups = 10,
          max_age = 30,
        },
      },
    ],
  },

  # Feature Flags
  features = {
    enable_audit_logging = true,
    enable_caching = true,
    enable_sampling = false,  # Experimental LLM sampling
    enable_experimental_tools = false,
  },

  # Performance Tuning
  performance = {
    # Thread pool sizes
    worker_threads = 4,
    blocking_threads = 2,

    # Timeouts
    default_timeout = 30000,  # milliseconds
    max_timeout = 300000,     # milliseconds

    # Buffering
    request_buffer_size = 1000,
    response_buffer_size = 1000,

    # Caching
    cache_enabled = true,
    cache_size = "256MB",
    cache_ttl = 3600,
  },
}
