Skip to content

Commit ccb070f

Browse files
stallentStephen Tallentmattt
authored
support 405 response from servers that don’t support streaming (#90)
* support 405 response from servers that don’t support streaming * Rephrase comment --------- Co-authored-by: Stephen Tallent <[email protected]> Co-authored-by: Mattt Zmuda <[email protected]>
1 parent f6e401a commit ccb070f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/MCP/Base/Transports/HTTPClientTransport.swift

+6
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+
// If the server returns 405 Method Not Allowed,
209+
// it indicates that the server doesn't support SSE streaming.
210+
// We should cancel the task instead of retrying the connection.
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)