Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`HTTPClientTransport` fails to build on Windows: `#if !os(Linux)` guards no longer match the `EventSource` platform condition

Aperta Adatta ai principianti
#261 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 7 giorni

Nessuno ha ancora preso questa issue.

  • #271 di @lionheart-jhanke — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
swift
Ambito
api, backend

Direzione di ricerca

Inizia confrontando la condizione EventSource in Package.swift con le cinque protezioni della piattaforma in Sources/MCP/Base/Transports/HTTPClientTransport.swift. Esegui swift build -c release su Windows, quindi verifica che i percorsi SSE di importazione e fallback utilizzino controlli di Availability corrispondenti e che il pacchetto venga compilato correttamente senza modificare il comportamento di Linux.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Swift
Stelle
1.5k
Fork
252
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/swift-sdk

Tutte le issue di modelcontextprotocol/swift-sdk

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.