Skip to content

Commit ea6c81a

Browse files
Stephen Tallentmattt
authored andcommitted
support 405 response from servers that don’t support streaming
1 parent f6e401a commit ea6c81a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/MCP/Base/Transports/HTTPClientTransport.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ public actor HTTPClientTransport: Actor, Transport {
205205

206206
// Check response status
207207
guard httpResponse.statusCode == 200 else {
208+
// For servers that don't support streaming from this endpoint
209+
// they should return a 405 NOT ALLOWED. So lets cancel the task
210+
// instead of retrying
211+
if httpResponse.statusCode == 405 {
212+
self.streamingTask?.cancel()
213+
}
208214
throw MCPError.internalError("HTTP error: \(httpResponse.statusCode)")
209215
}
210216

0 commit comments

Comments
 (0)