buildConnectorRef static method

ConnectorRef? buildConnectorRef({
  1. required MCPServer server,
  2. OAuthClientConfig? oauth,
})

Implementation

static ConnectorRef? buildConnectorRef({required MCPServer server, OAuthClientConfig? oauth}) {
  final clientSecretId = _oauthClientSecretIdFromHeaders(server);
  final serverUrl = server.serverUrl;
  final hasServerUrl = serverUrl != null && serverUrl.trim().isNotEmpty;
  final requiresOAuth = oauth != null || server.openaiConnectorId != null || clientSecretId != null;
  if (!requiresOAuth) {
    return null;
  }
  if (server.openaiConnectorId == null && clientSecretId == null && !hasServerUrl) {
    return null;
  }
  return ConnectorRef(
    openaiConnectorId: server.openaiConnectorId,
    serverUrl: hasServerUrl ? serverUrl.trim() : null,
    clientSecretId: clientSecretId,
  );
}