using xCommons.Constants; using xCommons.Extensions; using xAiModels.Constants; using xIdentityModels.Models; using xCommons.Configurations; using System.Collections.Generic; using xIdentityService.Constants; namespace xAiModels.Helpers { /// /// a Helper Class for Prepare Headers of MCP Client ... /// public static class XAiMcpHeaderBuilder { /// /// Build Headers for MCP Client Connection ... /// /// /// /// /// /// /// public static Dictionary Build( XAppConfiguration appConfiguration, string sessionId = null, string connectionId = null, XUserClaimsInfoDto userInfo = null, string protocolVersion = XAiMcpConstants.XAiMcpProtocol ) { // var headers = new Dictionary { // ["Accept"] = "application/json, text/event-stream", ["Content-Type"] = "application/json", [XAiMcpConstants.XAiMcpProtocolIdentifier] = protocolVersion, [XAuthorization.XPoweredBy] = appConfiguration.XPoweredValue ?? "xAiApi" }; // // Adding Authorization Headers ... if (!userInfo.IsNullOrDefault() && !userInfo.AccessToken.IsNullOrEmpty()) { // headers[XAuthorization.Header] = $"{XAuthorization.TokenIdentifier} {userInfo.AccessToken}"; headers[XAuthorization.ExpiresAt] = userInfo.ExpiresAt.ToString(); // if (!userInfo.RefreshToken.IsNullOrEmpty()) { headers[XAuthorization.RefreshToken] = userInfo.RefreshToken; } } // // شناسه اتصال (برای Push Notification ها) if (!connectionId.IsNullOrEmpty()) { headers[XHeader.ConnectionId.GetStringValue()] = connectionId; } // // Session Id ... if (!sessionId.IsNullOrEmpty()) { headers[XAiMcpConstants.XAiMcpSessionIdentifier] = sessionId; } // return headers; } } }