create static method
Create a new Streamable HTTP transport
Implementation
static Future<StreamableHttpClientTransport> create({
required String baseUrl,
McpOAuth? oauth,
Map<String, String>? headers,
RequestHeadersProvider? headersProvider,
Duration? headersProviderTimeout,
Duration? timeout,
int? maxConcurrentRequests,
bool? useHttp2,
http.Client? httpClient,
bool terminateOnClose = true, // Default: true for backward compatibility
}) async {
final config = StreamableHttpTransportConfig(
baseUrl: baseUrl,
oauth: oauth,
headers: headers ?? const {},
headersProvider: headersProvider,
headersProviderTimeout:
headersProviderTimeout ?? const Duration(seconds: 5),
timeout: timeout ?? const Duration(seconds: 30),
maxConcurrentRequests: maxConcurrentRequests ?? 10,
useHttp2: useHttp2 ?? true,
terminateOnClose: terminateOnClose,
);
final client = httpClient ?? http.Client();
return StreamableHttpClientTransport._(
config: config,
httpClient: client,
);
}