From c8c0cec2b408b58d1913ad91d2c605f83cb704a7 Mon Sep 17 00:00:00 2001 From: Tamer Abuelata <30121586+onetamer@users.noreply.github.com> Date: Sat, 29 Aug 2026 07:04:37 -0700 Subject: [PATCH] Guard EventSource usage out of Windows builds in HTTPClientTransport Package.swift provides the EventSource product only on Apple platforms (condition: .when(platforms: [.macOS, .iOS, ...])), but HTTPClientTransport.swift imports and uses it behind #if !os(Linux), so any Windows build of the MCP target fails with "no such module 'EventSource'". Widen every EventSource-related guard from os(Linux) to os(Linux) || os(Windows): Windows takes the same buffered (non-streaming) HTTP path Linux already takes, and SSE streaming is reported unsupported the same way. --- Sources/MCP/Base/Transports/HTTPClientTransport.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/MCP/Base/Transports/HTTPClientTransport.swift b/Sources/MCP/Base/Transports/HTTPClientTransport.swift index 060cd133..44d93c29 100644 --- a/Sources/MCP/Base/Transports/HTTPClientTransport.swift +++ b/Sources/MCP/Base/Transports/HTTPClientTransport.swift @@ -1,7 +1,7 @@ import Foundation import Logging -#if !os(Linux) +#if !os(Linux) && !os(Windows) import EventSource #endif @@ -266,7 +266,7 @@ public actor HTTPClientTransport: Transport { request = requestModifier(request) do { - #if os(Linux) + #if os(Linux) || os(Windows) let (responseData, response) = try await session.data(for: request) try await processResponse(response: response, data: responseData) #else @@ -304,7 +304,7 @@ public actor HTTPClientTransport: Transport { } } - #if os(Linux) + #if os(Linux) || os(Windows) private func processResponse(response: URLResponse, data: Data) async throws { guard let httpResponse = response as? HTTPURLResponse else { throw MCPError.internalError("Invalid HTTP response") @@ -467,7 +467,7 @@ public actor HTTPClientTransport: Transport { // MARK: - SSE private func startListeningForServerEvents() async { - #if os(Linux) + #if os(Linux) || os(Windows) if streaming { logger.warning( "SSE streaming was requested but is not fully supported on Linux. SSE connection will not be attempted." @@ -563,7 +563,7 @@ public actor HTTPClientTransport: Transport { #endif } - #if !os(Linux) + #if !os(Linux) && !os(Windows) private func connectToEventStream() async throws { guard isConnected else { logger.debug("⚠️ Skipping connectToEventStream - transport not connected")