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
@@ -235,10 +235,22 @@ public class StreamableHttpClientTransport(
235
235
}
236
236
logger.debug { "Client SSE session started successfully." }
237
237
} catch (e:SSEClientException) {
238
-
if (e.response?.status ==HttpStatusCode.MethodNotAllowed) {
238
+
val responseStatus = e.response?.status
239
+
val responseContentType = e.response?.contentType()
240
+
241
+
// 405 means server doesn't support SSE at GET endpoint - this is expected and valid
242
+
if (responseStatus ==HttpStatusCode.MethodNotAllowed) {
239
243
logger.info { "Server returned 405 for GET/SSE, stream disabled." }
240
244
return
241
245
}
246
+
247
+
// If server returns application/json, it means it doesn't support SSE for this session
248
+
// This is valid per spec - server can choose to only use JSON responses
249
+
if (responseContentType?.match(ContentType.Application.Json) ==true) {
250
+
logger.info { "Server returned application/json for GET/SSE, using JSON-only mode." }
0 commit comments