`HTTPClientTransport` fails to build on Windows: `#if !os(Linux)` guards no longer match the `EventSource` platform condition
Los mantenedores suelen responder en 7 días
Nadie ha tomado este issue todavía.
- #271 de @lionheart-jhanke — cerrado sin fusionar
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
Línea de trabajo
Comienza comparando la condición de EventSource en Package.swift con las cinco protecciones de plataforma en Sources/MCP/Base/Transports/HTTPClientTransport.swift. Ejecuta swift build -c release en Windows y, después, verifica que las rutas SSE de importación y fallback utilicen comprobaciones de Availability coincidentes y que el paquete se compile correctamente sin cambiar el comportamiento de Linux.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
On Windows, building any target that depends on MCP fails with:
error: no such module 'EventSource'
Sources/MCP/Base/Transports/HTTPClientTransport.swift:5:12
The source guards in HTTPClientTransport.swift and the EventSource dependency condition in Package.swift disagree about Windows, so the platform takes the Apple code path without the Apple dependency being linked.
Cause
Package.swift links EventSource on Apple platforms only:
.product(name: "EventSource", package: "eventsource",
condition: .when(platforms: [.macOS, .iOS, .tvOS, .visionOS, .watchOS, .macCatalyst]))
HTTPClientTransport.swift still gates its usage on Linux instead:
#if !os(Linux)
import EventSource
#endif
On Windows, !os(Linux) evaluates to true, so the import is compiled, but the product was never linked. The mirrored #if os(Linux) blocks that provide the fallback SSE path evaluate to false, so Windows gets neither path.
There are 5 such guards, all in Sources/MCP/Base/Transports/HTTPClientTransport.swift (lines 4, 269, 307, 470, 566).
Likely regression
This looks like an unintended consequence of #143 (merged 2025-08-10), which moved the platform logic out of Package.swift into an SPM .when(platforms:) condition. That PR changed Package.swift only; the #if !os(Linux) guards in the source were left as they were.
Before that change both sides keyed off the same !os(Linux) condition, so they could not drift. After it, Package.swift says "Apple only" while the source says "not Linux", and Windows sits in the gap.
Reproduction
Any package depending on MCP, built on Windows with Swift 6.3.2. Observed on windows-latest (GitHub Actions), swift-sdk 0.12.1:
swift build -c release
Suggested fix
Key both sides off availability rather than a platform denylist:
#if canImport(EventSource)
import EventSource
#endif
and invert the paired #if os(Linux) blocks to #if !canImport(EventSource). That keeps Linux behaviour identical and makes Windows take the same fallback path Linux already takes, without enumerating platforms in two places that can drift again.
Note
Linux is unaffected: its guards are consistent on both sides. This is Windows-only.
- Lenguaje dominante
- Swift
- Estrellas
- 1.5k
- Forks
- 252
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/swift-sdk
-
NetworkTransport leaks the underlying socket (CLOSE_WAIT) when reconnection is disabled and the receive loop terminatesPosiblemente ocupada @skirrellyjones la tomó hace 39 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
modelcontextprotocol/swift-sdk#282 ·
Los mantenedores suelen responder en 7 días
-
Value decoding changes data-URL-looking JSON strings into Value.dataPosiblemente ocupada @bitbemol la tomó hace 50 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
modelcontextprotocol/swift-sdk#277 ·
Los mantenedores suelen responder en 7 días
-
enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
modelcontextprotocol/swift-sdk#274 ·
Los mantenedores suelen responder en 7 días
-
Value: add numberValue (Double?) that coerces .int and .doublePosiblemente ocupada @gsdali la tomó hace 161 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
modelcontextprotocol/swift-sdk#225 ·
Los mantenedores suelen responder en 7 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
modelcontextprotocol/swift-sdk#287 · 1 comentario · 3 reacciones ·
Los mantenedores suelen responder en 7 días
Todos los issues de modelcontextprotocol/swift-sdk
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Emanuele-web04/remodex#203 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
Los mantenedores suelen responder en 1 día
-
test(BrainBar): inject synthetic observabilityCadence in BackupsHealth/one-page fixtures (DCI-1)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
EtanHey/brainlayer#1367 ·
Los mantenedores suelen responder en 1 día
-
cmux-next: new workspaces show no name instead of workspace-NPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: workspaces
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
manaflow-ai/cmux#21357 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 4 días