{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/stormmcp/json-schema/stormmcp-analytics-response-of-gateway-activity-response-schema.json",
  "title": "AnalyticsResponseOfGatewayActivityResponse",
  "description": "Generic wrapper for analytics responses.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/stormmcp-gatewayactivity-api-openapi.yml#/components/schemas/AnalyticsResponseOfGatewayActivityResponse",
  "type": "object",
  "properties": {
    "data": {
      "description": "Gets or sets the analytics data.",
      "$ref": "#/$defs/GatewayActivityResponse"
    },
    "metadata": {
      "description": "Gets or sets metadata about the response.",
      "$ref": "#/$defs/AnalyticsMetadata"
    },
    "fromCache": {
      "type": "boolean",
      "description": "Gets or sets a value indicating whether this data was cached."
    },
    "cacheAgeMinutes": {
      "pattern": "^-?(?:0|[1-9]\\d*)$",
      "type": [
        "null",
        "integer",
        "string"
      ],
      "description": "Gets or sets the cache age in minutes.",
      "format": "int32"
    }
  },
  "$defs": {
    "AnalyticsMetadata": {
      "type": "object",
      "properties": {
        "generatedAt": {
          "type": "string",
          "description": "Gets or sets when this data was generated.",
          "format": "date-time"
        },
        "dataSource": {
          "type": "string",
          "description": "Gets or sets the data source."
        },
        "queryParameters": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Gets or sets the query parameters used."
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Gets or sets any warnings or notes about the data."
        },
        "processingTimeMs": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the processing time in milliseconds.",
          "format": "int64"
        }
      },
      "description": "Metadata about analytics response."
    },
    "GatewayActivityPeriod": {
      "type": "object",
      "properties": {
        "periodStart": {
          "type": "string",
          "description": "Gets or sets the period start time.",
          "format": "date-time"
        },
        "periodEnd": {
          "type": "string",
          "description": "Gets or sets the period end time.",
          "format": "date-time"
        },
        "activeSessions": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of active sessions in this period.",
          "format": "int32"
        },
        "uniqueUsers": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of unique users in this period.",
          "format": "int32"
        },
        "methodCounts": {
          "type": "object",
          "additionalProperties": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "description": "Gets or sets the methods called in this period."
        },
        "assetUsageCounts": {
          "type": "object",
          "additionalProperties": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "description": "Gets or sets the specific assets/tools used in this period."
        },
        "gatewayCounts": {
          "type": "object",
          "additionalProperties": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "description": "Gets or sets the per-gateway request counts in this period, keyed by gateway display name."
        },
        "gatewayBreakdown": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GatewayActivityPeriodGateway"
          },
          "description": "Gets or sets the per-gateway request counts in this period with the gateway's identity carried\nstructurally (MCPG-2095), so a caller can label and key a series without matching\nDictionary&lt;string, int&gt; GatewayActivityPeriod.GatewayCounts display-name text. One entry per (gateway id, row-less session type);\ncarries the same rows as Dictionary&lt;string, int&gt; GatewayActivityPeriod.GatewayCounts, which is kept for callers that predate it."
        },
        "totalCalls": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the total number of request log entries in this period.",
          "format": "int32"
        },
        "failedCalls": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of failed calls in this period.",
          "format": "int32"
        },
        "errorRate": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the error rate in this period as a decimal (0.0 to 1.0).",
          "format": "double"
        }
      },
      "description": "Activity data for a specific time period."
    },
    "GatewayActivityPeriodGateway": {
      "type": "object",
      "properties": {
        "gatewayId": {
          "type": "string",
          "description": "Gets or sets the gateway configuration ID. Guid Guid.Empty for a row-less session.",
          "format": "uuid"
        },
        "sessionType": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "description": "Gets or sets the session type of a row-less session: set only when Guid GatewayActivityPeriodGateway.GatewayId is\nGuid Guid.Empty, where it tells McpSessionType.Dynamic from\nMcpSessionType.Ephemeral (null there means a legacy row). Null for a resolved gateway.",
              "$ref": "#/$defs/McpSessionType"
            }
          ]
        },
        "gatewayName": {
          "type": "string",
          "description": "Gets or sets the gateway display name, as Dictionary&lt;string, int&gt; GatewayActivityPeriod.GatewayCounts keys it."
        },
        "count": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of request log entries in the period.",
          "format": "int32"
        }
      },
      "description": "Request count for one gateway in one activity period, with the gateway's identity (MCPG-2095)."
    },
    "GatewayActivityResponse": {
      "type": "object",
      "properties": {
        "summary": {
          "description": "Gets or sets the summary statistics for the period.",
          "$ref": "#/$defs/GatewayActivitySummary"
        },
        "sessions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GatewaySessionDetail"
          },
          "description": "Gets or sets the detailed session information."
        },
        "activityByPeriod": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GatewayActivityPeriod"
          },
          "description": "Gets or sets the activity breakdown by time period based on granularity."
        }
      },
      "description": "Response model for gateway activity analytics."
    },
    "GatewayActivitySummary": {
      "type": "object",
      "properties": {
        "totalActiveSessions": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the total number of active sessions in the period.",
          "format": "int32"
        },
        "uniqueUsers": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of unique users with sessions.",
          "format": "int32"
        },
        "uniqueGateways": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of unique gateway configurations used.",
          "format": "int32"
        },
        "totalGatewaysAvailable": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the total number of gateway configurations available.",
          "format": "int32"
        },
        "averageSessionDurationMinutes": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the average session duration in minutes.",
          "format": "double"
        },
        "methodCounts": {
          "type": "object",
          "additionalProperties": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "description": "Gets or sets the methods called during this period."
        },
        "assetUsageCounts": {
          "type": "object",
          "additionalProperties": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "description": "Gets or sets the specific tools/assets called during this period (when method is tools/call, prompts/get, etc.)."
        },
        "totalCalls": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the total number of request log entries in the period.",
          "format": "int32"
        },
        "failedCalls": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of failed calls (error or denied status).",
          "format": "int32"
        },
        "errorRate": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the error rate as a decimal (0.0 to 1.0).",
          "format": "double"
        },
        "p50LatencyMs": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the 50th percentile latency in milliseconds.",
          "format": "double"
        },
        "p95LatencyMs": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the 95th percentile latency in milliseconds.",
          "format": "double"
        },
        "p99LatencyMs": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the 99th percentile latency in milliseconds.",
          "format": "double"
        },
        "previousPeriodTotalCalls": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "null",
            "integer",
            "string"
          ],
          "description": "Gets or sets the total calls in the previous period (for delta comparison). Null if not requested.",
          "format": "int32"
        },
        "previousPeriodErrorRate": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "null",
            "number",
            "string"
          ],
          "description": "Gets or sets the error rate in the previous period. Null if not requested.",
          "format": "double"
        },
        "previousPeriodP95LatencyMs": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "null",
            "number",
            "string"
          ],
          "description": "Gets or sets the P95 latency in the previous period in milliseconds. Null if not requested.",
          "format": "double"
        },
        "topTools": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TopToolDetail"
          },
          "description": "Gets or sets the detailed top tools list with per-tool metrics."
        }
      },
      "description": "Summary statistics for gateway activity."
    },
    "GatewaySessionDetail": {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "description": "Gets or sets the session ID."
        },
        "gatewayId": {
          "type": "string",
          "description": "Gets or sets the gateway configuration ID.",
          "format": "uuid"
        },
        "userId": {
          "type": "string",
          "description": "Gets or sets the user ID."
        },
        "registeredAt": {
          "type": "string",
          "description": "Gets or sets when the session was registered.",
          "format": "date-time"
        },
        "lastActiveAt": {
          "type": "string",
          "description": "Gets or sets when the session was last active.",
          "format": "date-time"
        },
        "durationMinutes": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the session duration in minutes.",
          "format": "double"
        },
        "isActive": {
          "type": "boolean",
          "description": "Gets or sets a value indicating whether the session is currently active."
        }
      },
      "description": "Detailed information about a gateway session."
    },
    "McpSessionType": {
      "type": "integer"
    },
    "TopToolDetail": {
      "type": "object",
      "properties": {
        "toolName": {
          "type": "string",
          "description": "Gets or sets the tool/asset name."
        },
        "serverName": {
          "type": [
            "null",
            "string"
          ],
          "description": "Gets or sets the upstream MCP server name."
        },
        "gatewayName": {
          "type": [
            "null",
            "string"
          ],
          "description": "Gets or sets the gateway name."
        },
        "gatewayId": {
          "type": "string",
          "description": "Gets or sets the gateway configuration ID.",
          "format": "uuid"
        },
        "sessionType": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "description": "Gets or sets the session type of a row-less session (MCPG-2042): set only when Guid TopToolDetail.GatewayId is\nGuid Guid.Empty, where it is the structural signal that tells a\nMcpSessionType.Dynamic tool from an McpSessionType.Ephemeral one (and null\nthere means a legacy row). Rows are grouped by (tool, gateway, row-less session type), so those two are\nseparate rows while a resolved gateway keeps one row per tool whichever entry point served it, and carries\nnull here.",
              "$ref": "#/$defs/McpSessionType"
            }
          ]
        },
        "callCount": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the total number of calls to this tool.",
          "format": "int32"
        },
        "errorCount": {
          "pattern": "^-?(?:0|[1-9]\\d*)$",
          "type": [
            "integer",
            "string"
          ],
          "description": "Gets or sets the number of calls that resulted in an error or denied status.",
          "format": "int32"
        },
        "avgLatencyMs": {
          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
          "type": [
            "number",
            "string"
          ],
          "description": "Gets or sets the average latency in milliseconds for calls to this tool.",
          "format": "double"
        }
      },
      "description": "Detailed information about a top tool by usage."
    }
  }
}