create static method

Future<StreamableHttpClientTransport> create({
  1. required String baseUrl,
  2. McpOAuth? oauth,
  3. Map<String, String>? headers,
  4. RequestHeadersProvider? headersProvider,
  5. Duration? headersProviderTimeout,
  6. Duration? timeout,
  7. int? maxConcurrentRequests,
  8. bool? useHttp2,
  9. Client? httpClient,
  10. bool terminateOnClose = true,
})

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,
  );
}