File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ if result.capabilities.tools != nil {
6262}
6363```
6464
65+ > [ !NOTE]
66+ > The ` Client.connect(transport:) ` method returns the initialization result.
67+ > This return value is discardable,
68+ > so you can ignore it if you don't need to check server capabilities.
69+
6570### Transport Options for Clients
6671
6772#### Stdio Transport
@@ -71,7 +76,7 @@ For local subprocess communication:
7176``` swift
7277// Create a stdio transport (simplest option)
7378let transport = StdioTransport ()
74- let result = try await client.connect (transport : transport)
79+ try await client.connect (transport : transport)
7580```
7681
7782#### HTTP Transport
@@ -84,7 +89,7 @@ let transport = HTTPClientTransport(
8489 endpoint : URL (string : " http://localhost:8080" )! ,
8590 streaming : true // Enable Server-Sent Events for real-time updates
8691)
87- let result = try await client.connect (transport : transport)
92+ try await client.connect (transport : transport)
8893```
8994
9095### Tools
@@ -192,7 +197,7 @@ Handle common client errors:
192197
193198``` swift
194199do {
195- let result = try await client.initialize ()
200+ try await client.connect ()
196201 // Success
197202} catch let error as MCPError {
198203 print (" MCP Error: \( error.localizedDescription ) " )
Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ public actor Client {
168168 }
169169
170170 /// Connect to the server using the given transport
171+ @discardableResult
171172 public func connect( transport: any Transport ) async throws -> Initialize . Result {
172173 self . connection = transport
173174 try await self . connection? . connect ( )
You can’t perform that action at this time.
0 commit comments