`HTTPClientTransport` fails to build on Windows: `#if !os(Linux)` guards no longer match the `EventSource` platform condition
メンテナーはふだん 7 日以内に返信
まだ誰も着手していません。
- #271 @lionheart-jhanke による — マージされずにクローズ
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 85/100
調査の方向性
まず、Package.swift の EventSource 条件と Sources/MCP/Base/Transports/HTTPClientTransport.swift にある 5 つのプラットフォームガードを比較します。Windows で swift build -c release を実行し、その後、import と fallback の SSE パスが一致する Availability チェックを使用していること、および Linux の動作を変更せずにパッケージが正常にビルドされることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Swift
- スター
- 1.5k
- フォーク
- 254
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/swift-sdk のほかの issue
-
NetworkTransport leaks the underlying socket (CLOSE_WAIT) when reconnection is disabled and the receive loop terminates対応中かも @skirrellyjones が 43 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
modelcontextprotocol/swift-sdk#282 ·
メンテナーはふだん 7 日以内に返信
-
Value decoding changes data-URL-looking JSON strings into Value.data対応中かも @bitbemol が 53 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
modelcontextprotocol/swift-sdk#277 ·
メンテナーはふだん 7 日以内に返信
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
modelcontextprotocol/swift-sdk#274 ·
メンテナーはふだん 7 日以内に返信
-
Value: add numberValue (Double?) that coerces .int and .double対応中かも @gsdali が 164 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
modelcontextprotocol/swift-sdk#225 ·
メンテナーはふだん 7 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
modelcontextprotocol/swift-sdk#287 · コメント 1 件 · リアクション 3 件 ·
メンテナーはふだん 7 日以内に返信
modelcontextprotocol/swift-sdk の issue をすべて見る
似ている issue
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
marcovisona/arca#5 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
luis-guillen/airy#2 ·
-
accessibility bug medium-priority mobile
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
lognorman20/monaco#6247 ·
-
documentation windows
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4060 ·