Use EventSource for SSE implementation (#96)

* Add package dependency for github.com/loopwork-ai/EventSource

* Use EventSource for SSE implementation

* Refactor response stream and content type handling

Co-authored-by: Stephen Tallent <stallent@mercury.io>

* Conditionalize use of streaming for supported platforms

* Refactor conditional platform handling

* Conditionalize code and package dependency on Linux

---------

Co-authored-by: Stephen Tallent <stallent@mercury.io>
This commit is contained in:
Mattt 2025-05-06 05:45:40 -07:00 • committed by GitHub
commit 3ff1085e01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,25 @@
import PackageDescription
// Base dependencies needed on all platforms
var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
]
// Target dependencies needed on all platforms
var targetDependencies: [Target.Dependency] = [
.product(name: "SystemPackage", package: "swift-system"),
.product(name: "Logging", package: "swift-log"),
]
// Add EventSource only on Apple platforms (non-Linux)
#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"))
#endif
let package = Package(
name: "mcp-swift-sdk",
platforms: [
@ -19,25 +38,15 @@ let package = Package(
name: "MCP",
targets: ["MCP"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
],
dependencies: dependencies,
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "MCP",
dependencies: [
.product(name: "SystemPackage", package: "swift-system"),
.product(name: "Logging", package: "swift-log"),
]),
dependencies: targetDependencies),
.testTarget(
name: "MCPTests",
dependencies: [
"MCP",
.product(name: "SystemPackage", package: "swift-system"),
.product(name: "Logging", package: "swift-log"),
]),
dependencies: ["MCP"] + targetDependencies),
]
)