Skip to content

Commit 3ff1085

Browse files
matttStephen Tallent
andauthored
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 <[email protected]> * Conditionalize use of streaming for supported platforms * Refactor conditional platform handling * Conditionalize code and package dependency on Linux --------- Co-authored-by: Stephen Tallent <[email protected]>
1 parent 2b67a12 commit 3ff1085

File tree

4 files changed

+193
-143
lines changed

4 files changed

+193
-143
lines changed

Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33

44
import PackageDescription
55

6+
// Base dependencies needed on all platforms
7+
var dependencies: [Package.Dependency] = [
8+
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
9+
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
10+
]
11+
12+
// Target dependencies needed on all platforms
13+
var targetDependencies: [Target.Dependency] = [
14+
.product(name: "SystemPackage", package: "swift-system"),
15+
.product(name: "Logging", package: "swift-log"),
16+
]
17+
18+
// Add EventSource only on Apple platforms (non-Linux)
19+
#if !os(Linux)
20+
dependencies.append(
21+
.package(url: "https://github.com/loopwork-ai/eventsource.git", from: "1.1.0"))
22+
targetDependencies.append(.product(name: "EventSource", package: "eventsource"))
23+
#endif
24+
625
let package = Package(
726
name: "mcp-swift-sdk",
827
platforms: [
@@ -19,25 +38,15 @@ let package = Package(
1938
name: "MCP",
2039
targets: ["MCP"])
2140
],
22-
dependencies: [
23-
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
24-
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
25-
],
41+
dependencies: dependencies,
2642
targets: [
2743
// Targets are the basic building blocks of a package, defining a module or a test suite.
2844
// Targets can depend on other targets in this package and products from dependencies.
2945
.target(
3046
name: "MCP",
31-
dependencies: [
32-
.product(name: "SystemPackage", package: "swift-system"),
33-
.product(name: "Logging", package: "swift-log"),
34-
]),
47+
dependencies: targetDependencies),
3548
.testTarget(
3649
name: "MCPTests",
37-
dependencies: [
38-
"MCP",
39-
.product(name: "SystemPackage", package: "swift-system"),
40-
.product(name: "Logging", package: "swift-log"),
41-
]),
50+
dependencies: ["MCP"] + targetDependencies),
4251
]
4352
)

0 commit comments

Comments
 (0)