From 8185c354aef8be5f33118db5808fee47e61a5b02 Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Wed, 6 Aug 2025 23:20:09 +0200 Subject: [PATCH 1/7] enable building with the Swift Linux SDK --- Package.swift | 5 ++++- Sources/MCP/Base/Transports/StdioTransport.swift | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index 9f1cb351..4cf6febe 100644 --- a/Package.swift +++ b/Package.swift @@ -19,7 +19,10 @@ var targetDependencies: [Target.Dependency] = [ #if !os(Linux) dependencies.append( .package(url: "https://github.com/loopwork-ai/eventsource.git", from: "1.1.0")) - targetDependencies.append(.product(name: "EventSource", package: "eventsource")) + targetDependencies.append( + .product( + name: "EventSource", package: "eventsource", + condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .visionOS]))) #endif let package = Package( diff --git a/Sources/MCP/Base/Transports/StdioTransport.swift b/Sources/MCP/Base/Transports/StdioTransport.swift index cd9f1ae1..1250c5b8 100644 --- a/Sources/MCP/Base/Transports/StdioTransport.swift +++ b/Sources/MCP/Base/Transports/StdioTransport.swift @@ -13,9 +13,11 @@ import struct Foundation.Data import Darwin.POSIX #elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) + import Musl #endif -#if canImport(Darwin) || canImport(Glibc) +#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) /// An implementation of the MCP stdio transport protocol. /// /// This transport implements the [stdio transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio) @@ -107,7 +109,7 @@ import struct Foundation.Data /// - Parameter fileDescriptor: The file descriptor to configure /// - Throws: Error if the operation fails private func setNonBlocking(fileDescriptor: FileDescriptor) throws { - #if canImport(Darwin) || canImport(Glibc) + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) // Get current flags let flags = fcntl(fileDescriptor.rawValue, F_GETFL) guard flags >= 0 else { From fe3143073946e15e876efddf787aaf244e689c40 Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Thu, 14 Aug 2025 00:17:20 +0200 Subject: [PATCH 2/7] add ci step --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1942e300..6d604488 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: os: [macos-latest, ubuntu-latest] swift-version: - 6.0.3 - - 6.1.0 + - 6.1.2 runs-on: ${{ matrix.os }} name: Test (${{ matrix.os }}, Swift ${{ matrix.swift-version }}) @@ -42,3 +42,22 @@ jobs: - name: Run tests run: swift test -v + + static-linux-sdk-build: + name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.os }}) + strategy: + matrix: + os: [ubuntu-latest] + swift-version: + - 6.1.2 + runs-on: ${{ matrix.os }} + container: swift:${{ matrix.swift-version }}-noble + timeout-minutes: 30 + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Install static SDK and build + run: | + which curl || (apt -q update && apt -yq install curl) + curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + bash -s -- --static ${{ matrix.swift-version }} From 5f1dd10edd41c8e8d0e7b565a1f35d82a98e2fff Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Thu, 14 Aug 2025 00:38:02 +0200 Subject: [PATCH 3/7] revert version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d604488..151a761c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: os: [macos-latest, ubuntu-latest] swift-version: - 6.0.3 - - 6.1.2 + - 6.1.0 runs-on: ${{ matrix.os }} name: Test (${{ matrix.os }}, Swift ${{ matrix.swift-version }}) From b508625547e075785d6031a4963d56709c5e9648 Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Thu, 14 Aug 2025 00:56:05 +0200 Subject: [PATCH 4/7] use triple --- .github/workflows/ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 151a761c..212dbdc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,12 +44,15 @@ jobs: run: swift test -v static-linux-sdk-build: - name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.os }}) + name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.triple }}) strategy: matrix: os: [ubuntu-latest] swift-version: - 6.1.2 + --triple: + - aarch64-swift-linux-musl + - x86_64-swift-linux-musl runs-on: ${{ matrix.os }} container: swift:${{ matrix.swift-version }}-noble timeout-minutes: 30 @@ -57,7 +60,9 @@ jobs: - name: Check out code uses: actions/checkout@v4 - name: Install static SDK and build + env: + BUILD_FLAGS: --triple ${{ matrix.triple }} run: | which curl || (apt -q update && apt -yq install curl) curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --static ${{ matrix.swift-version }} + bash -s -- --static --flags="$BUILD_FLAGS" ${{ matrix.swift-version }} From dadaeeaf1674dbf8605f6bd04a543f9d70f7120d Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Thu, 14 Aug 2025 00:57:47 +0200 Subject: [PATCH 5/7] triple --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 212dbdc1..f220a30a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: os: [ubuntu-latest] swift-version: - 6.1.2 - --triple: + triple: - aarch64-swift-linux-musl - x86_64-swift-linux-musl runs-on: ${{ matrix.os }} From 69347edd8aa85106738b9deae310f3a4e312f4db Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Thu, 14 Aug 2025 08:08:10 +0200 Subject: [PATCH 6/7] remove triple --- .github/workflows/ci.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f220a30a..f586c9cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,17 +42,14 @@ jobs: - name: Run tests run: swift test -v - + static-linux-sdk-build: - name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.triple }}) + name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.os }}) strategy: matrix: os: [ubuntu-latest] swift-version: - 6.1.2 - triple: - - aarch64-swift-linux-musl - - x86_64-swift-linux-musl runs-on: ${{ matrix.os }} container: swift:${{ matrix.swift-version }}-noble timeout-minutes: 30 @@ -61,7 +58,7 @@ jobs: uses: actions/checkout@v4 - name: Install static SDK and build env: - BUILD_FLAGS: --triple ${{ matrix.triple }} + BUILD_FLAGS: "" run: | which curl || (apt -q update && apt -yq install curl) curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ From fb6ab598d88f3275265e0296fbd20f947aa27a73 Mon Sep 17 00:00:00 2001 From: Tobias Haeberle Date: Thu, 14 Aug 2025 11:29:33 +0200 Subject: [PATCH 7/7] reset changes to Package.resolved --- Package.resolved | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index 1b27adca..5e9023c5 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,13 +1,13 @@ { - "originHash" : "56af283ce9bd05659ed22f118d39d6cdfb6f7372adfccb948cdb3da72e0483c9", + "originHash" : "08de61941b7919a65e36c0e34f8c1c41995469b86a39122158b75b4a68c4527d", "pins" : [ { "identity" : "eventsource", "kind" : "remoteSourceControl", - "location" : "https://github.com/mattt/eventsource.git", + "location" : "https://github.com/loopwork-ai/eventsource.git", "state" : { - "revision" : "07957602bb99a5355c810187e66e6ce378a1057d", - "version" : "1.1.1" + "revision" : "e83f076811f32757305b8bf69ac92d05626ffdd7", + "version" : "1.1.0" } }, {