{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "servers"],
  "properties": {
    "schemaVersion": { "const": 2 },
    "servers": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["provider", "description", "transport", "risk", "activation", "clients"],
        "properties": {
          "provider": { "type": "string", "minLength": 1 },
          "description": { "type": "string", "minLength": 1 },
          "transport": { "enum": ["stdio", "http"] },
          "endpoint": { "type": "string", "pattern": "^https://" },
          "startupTimeoutSeconds": { "type": "integer", "minimum": 1 },
          "risk": { "enum": ["low", "medium", "high"] },
          "activation": { "enum": ["off", "registered", "project", "auto", "always"] },
          "commonArgs": { "type": "array", "items": { "type": "string" } },
          "clients": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "codex": { "$ref": "#/definitions/client" },
              "claude": { "$ref": "#/definitions/client" },
              "opencode": { "$ref": "#/definitions/client" }
            }
          }
        },
        "allOf": [
          { "if": { "properties": { "transport": { "const": "http" } } }, "then": { "required": ["endpoint"] } }
        ]
      }
    }
  },
  "definitions": {
    "client": {
      "type": "object",
      "additionalProperties": false,
      "required": ["scope"],
      "properties": {
        "scope": { "enum": ["user", "project"] },
        "context": { "type": "string", "minLength": 1 }
      }
    }
  }
}
