package com.iot.gateway.admin; import com.iot.gateway.common.Result; import com.iot.gateway.mcp.McpToolRegistry; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @Tag(name = "网关运行状态与能力目录") @RestController @RequestMapping("/open/gateway") public class OpenGatewayInfoController { @Autowired private McpToolRegistry toolRegistry; @Operation(summary = "网关健康检查探针") @GetMapping("/health") public Result> health() { return Result.success(Map.of( "status", "ONLINE", "service", "iot-open-gateway", "timestamp", System.currentTimeMillis() )); } @Operation(summary = "拉取可用能力目录 (MCP Tools 与 OpenAPI)") @GetMapping("/catalog") public Result> catalog() { List> tools = toolRegistry.getToolDefinitions(); List apis = List.of( "GET /open/v1/devices (租户设备台账与状态)", "GET /open/v1/devices/{id} (单设备详情与点位定义)", "GET /open/v1/telemetry/latest (设备最新实时工况召测)", "GET /open/v1/telemetry/history (时序历史遥测点位拉取)", "POST /open/v1/commands (设备控制指令反写下发)", "GET /open/v1/alarms (故障报警检索与确认)" ); return Result.success(Map.of( "status", "ONLINE", "mcpEndpoint", "/mcp/sse", "tokenEndpoint", "/oauth2/token", "toolCount", tools.size(), "tools", tools, "openApis", apis )); } }