@@ -58,11 +58,11 @@ public async Task ConnectAsync(CancellationToken cancellationToken = default)
58
58
59
59
await _connectionEstablished . Task . WaitAsync ( _options . ConnectionTimeout , cancellationToken ) . ConfigureAwait ( false ) ;
60
60
}
61
- catch ( Exception ex ) when ( ex is not McpTransportException ) // propagate transport exceptions
61
+ catch ( Exception ex )
62
62
{
63
63
LogTransportConnectFailed ( Name , ex ) ;
64
64
await CloseAsync ( ) . ConfigureAwait ( false ) ;
65
- throw new McpTransportException ( "Failed to connect transport" , ex ) ;
65
+ throw new InvalidOperationException ( "Failed to connect transport" , ex ) ;
66
66
}
67
67
}
68
68
@@ -110,7 +110,7 @@ public override async Task SendMessageAsync(
110
110
else
111
111
{
112
112
JsonRpcResponse initializeResponse = JsonSerializer . Deserialize ( responseContent , McpJsonUtilities . JsonContext . Default . JsonRpcResponse ) ??
113
- throw new McpTransportException ( "Failed to initialize client" ) ;
113
+ throw new InvalidOperationException ( "Failed to initialize client" ) ;
114
114
115
115
LogTransportReceivedMessage ( Name , messageId ) ;
116
116
await WriteMessageAsync ( initializeResponse , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -136,7 +136,7 @@ public override async Task SendMessageAsync(
136
136
LogRejectedPost ( Name , messageId ) ;
137
137
}
138
138
139
- throw new McpTransportException ( "Failed to send message" ) ;
139
+ throw new InvalidOperationException ( "Failed to send message" ) ;
140
140
}
141
141
}
142
142
@@ -273,34 +273,18 @@ private async Task ProcessSseMessage(string data, CancellationToken cancellation
273
273
274
274
private void HandleEndpointEvent ( string data )
275
275
{
276
- try
276
+ if ( string . IsNullOrEmpty ( data ) )
277
277
{
278
- if ( string . IsNullOrEmpty ( data ) )
279
- {
280
- LogTransportEndpointEventInvalid ( Name ) ;
281
- return ;
282
- }
283
-
284
- // If data is an absolute URL, the Uri will be constructed entirely from it and not the _sseEndpoint.
285
- _messageEndpoint = new Uri ( _sseEndpoint , data ) ;
286
-
287
- // Set connected state
288
- SetConnected ( true ) ;
289
- _connectionEstablished . TrySetResult ( true ) ;
278
+ LogTransportEndpointEventInvalid ( Name ) ;
279
+ return ;
290
280
}
291
- catch ( JsonException ex )
292
- {
293
- if ( _logger . IsEnabled ( LogLevel . Trace ) )
294
- {
295
- LogTransportEndpointEventParseFailedSensitive ( Name , data , ex ) ;
296
- }
297
- else
298
- {
299
- LogTransportEndpointEventParseFailed ( Name , ex ) ;
300
- }
301
281
302
- throw new McpTransportException ( "Failed to parse endpoint event" , ex ) ;
303
- }
282
+ // If data is an absolute URL, the Uri will be constructed entirely from it and not the _sseEndpoint.
283
+ _messageEndpoint = new Uri ( _sseEndpoint , data ) ;
284
+
285
+ // Set connected state
286
+ SetConnected ( true ) ;
287
+ _connectionEstablished . TrySetResult ( true ) ;
304
288
}
305
289
306
290
private void CopyAdditionalHeaders ( HttpRequestHeaders headers )
0 commit comments