You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: kotlin-sdk-client/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/StreamableHttpClientTransport.kt
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -234,10 +234,22 @@ public class StreamableHttpClientTransport(
234
234
}
235
235
logger.debug { "Client SSE session started successfully." }
236
236
} catch (e:SSEClientException) {
237
-
if (e.response?.status ==HttpStatusCode.MethodNotAllowed) {
237
+
val responseStatus = e.response?.status
238
+
val responseContentType = e.response?.contentType()
239
+
240
+
// 405 means server doesn't support SSE at GET endpoint - this is expected and valid
241
+
if (responseStatus ==HttpStatusCode.MethodNotAllowed) {
238
242
logger.info { "Server returned 405 for GET/SSE, stream disabled." }
239
243
return
240
244
}
245
+
246
+
// If server returns application/json, it means it doesn't support SSE for this session
247
+
// This is valid per spec - server can choose to only use JSON responses
248
+
if (responseContentType?.match(ContentType.Application.Json) ==true) {
249
+
logger.info { "Server returned application/json for GET/SSE, using JSON-only mode." }
0 commit comments