We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 48c19c2 commit 2b67a12Copy full SHA for 2b67a12
Sources/MCP/Base/Transports/NetworkTransport.swift
@@ -168,6 +168,11 @@ import struct Foundation.Data
168
while isConnected && !Task.isCancelled {
169
do {
170
let newData = try await receiveData()
171
+ // Check for EOF (empty data)
172
+ if newData.isEmpty {
173
+ logger.info("Connection closed by peer (EOF).")
174
+ break // Exit loop gracefully
175
+ }
176
buffer.append(newData)
177
178
// Process complete messages
@@ -219,8 +224,8 @@ import struct Foundation.Data
219
224
} else if let content = content {
220
225
continuation.resume(returning: content)
221
226
} else {
222
- continuation.resume(
223
- throwing: MCPError.internalError("No data received"))
227
+ // EOF: Resume with empty data instead of throwing an error
228
+ continuation.resume(returning: Data())
229
}
230
231
0 commit comments