Skip to content

Commit 7ac5c4a

Browse files
committed
Update signature and make test explicit
1 parent 0504aee commit 7ac5c4a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/ModelContextProtocol/Protocol/Transport/SseClientTransport.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ public SseClientTransport(SseClientTransportOptions transportOptions, HttpClient
5858
/// <param name="transportOptions">Configuration options for the transport.</param>
5959
/// <param name="authorizationProvider">The authorization provider to use for authentication.</param>
6060
/// <param name="loggerFactory">Logger factory for creating loggers used for diagnostic output during transport operations.</param>
61-
public SseClientTransport(SseClientTransportOptions transportOptions, ITokenProvider authorizationProvider, ILoggerFactory? loggerFactory = null)
61+
/// <param name="baseMessageHandler">Optional. The base message handler to use under the authorization handler.
62+
/// If null, a new <see cref="HttpClientHandler"/> will be used. This allows for custom HTTP client pipelines (e.g., from HttpClientFactory)
63+
/// to be used in conjunction with the token-based authentication provided by <paramref name="authorizationProvider"/>.</param>
64+
public SseClientTransport(SseClientTransportOptions transportOptions, ITokenProvider authorizationProvider, ILoggerFactory? loggerFactory = null, HttpMessageHandler? baseMessageHandler = null)
6265
{
6366
Throw.IfNull(transportOptions);
6467
Throw.IfNull(authorizationProvider);
@@ -67,13 +70,11 @@ public SseClientTransport(SseClientTransportOptions transportOptions, ITokenProv
6770
_loggerFactory = loggerFactory;
6871
Name = transportOptions.Name ?? transportOptions.Endpoint.ToString();
6972

70-
// Create an auth handler with the authorization provider
7173
var authHandler = new AuthorizationDelegatingHandler(authorizationProvider)
7274
{
73-
InnerHandler = new HttpClientHandler()
75+
InnerHandler = baseMessageHandler ?? new HttpClientHandler()
7476
};
7577

76-
// Create an HttpClient with the auth handler
7778
_httpClient = new HttpClient(authHandler);
7879
_ownsHttpClient = true;
7980
}

tests/ModelContextProtocol.Tests/Transport/SseClientTransportTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void Constructor_Throws_For_Null_Options()
3535
[Fact]
3636
public void Constructor_Throws_For_Null_HttpClient()
3737
{
38-
var exception = Assert.Throws<ArgumentNullException>(() => new SseClientTransport(_transportOptions, null!, LoggerFactory));
38+
var exception = Assert.Throws<ArgumentNullException>(() => new SseClientTransport(_transportOptions, httpClient: null!, LoggerFactory));
3939
Assert.Equal("httpClient", exception.ParamName);
4040
}
4141

0 commit comments

Comments
 (0)