package com.vincent.rsf.server.api.controller.mcp; import com.fasterxml.jackson.databind.JsonNode; import com.vincent.rsf.server.ai.service.mcp.AiMcpProtocolService; import com.vincent.rsf.server.system.controller.BaseController; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @RestController @RequestMapping("/ai/mcp") public class AiMcpProtocolController extends BaseController { @Resource private AiMcpProtocolService aiMcpProtocolService; @PostMapping public Object handle(@RequestBody JsonNode body, @RequestHeader(value = "X-Tenant-Id", required = false) String tenantHeader, @RequestParam(value = "tenantId", required = false) Long tenantParam) { Long tenantId = resolveTenantId(tenantHeader, tenantParam); return aiMcpProtocolService.handle(tenantId, body); } private Long resolveTenantId(String tenantHeader, Long tenantParam) { if (tenantParam != null) { return tenantParam; } if (tenantHeader != null && !tenantHeader.trim().isEmpty()) { try { return Long.valueOf(tenantHeader.trim()); } catch (Exception ignore) { } } Long loginTenantId = getTenantId(); return loginTenantId == null ? 1L : loginTenantId; } }