File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ public actor MCPClient {
99 private var messageStream : AsyncStream < SSEMessage > ?
1010 private var streamTask : Task < Void , Never > ?
1111 private let endpointURL : URL
12+ private let session : URLSession
1213
1314 /// Initialize a new MCP client with the SSE endpoint URL
1415 /// - Parameter endpointURL: The URL of the SSE endpoint (e.g. http://localhost:8080/sse)
1516 public init ( endpointURL: URL ) {
1617 self . endpointURL = endpointURL
18+ self . session = URLSession ( configuration: . default)
1719 }
1820
1921 /// Connect to the SSE endpoint and establish a connection
@@ -71,7 +73,7 @@ public actor MCPClient {
7173 request. httpBody = try encoder. encode ( message)
7274
7375 // Send the request
74- let ( _, response) = try await URLSession . shared . data ( for: request)
76+ let ( _, response) = try await session . data ( for: request)
7577
7678 guard let httpResponse = response as? HTTPURLResponse ,
7779 httpResponse. statusCode == 202 else {
Original file line number Diff line number Diff line change @@ -115,7 +115,8 @@ func testOPENAPI() async throws {
115115 try await transport. start ( )
116116
117117 let openAPIURL = endpointURL. appending ( component: " openapi.json " )
118- let ( openAPIData, openAPIResponse) = try await URLSession . shared. data ( from: openAPIURL)
118+ let session = URLSession ( configuration: . default)
119+ let ( openAPIData, openAPIResponse) = try await session. data ( from: openAPIURL)
119120 let openAPIHTTPResponse = unwrap ( openAPIResponse as? HTTPURLResponse )
120121 #expect( openAPIHTTPResponse. statusCode == 200 )
121122
You can’t perform that action at this time.
0 commit comments