Skip to content

Commit 54cf16b

Browse files
committed
Deprecate initialize method
1 parent c243e6b commit 54cf16b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Sources/MCP/Client/Client.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ public actor Client {
220220
}
221221

222222
// Automatically initialize after connecting
223-
let result = try await initialize()
224-
return result
223+
return try await _initialize()
225224
}
226225

227226
/// Disconnect the client and cancel all pending requests
@@ -485,7 +484,23 @@ public actor Client {
485484

486485
// MARK: - Lifecycle
487486

487+
/// Initialize the connection with the server.
488+
///
489+
/// - Important: This method is deprecated. Initialization now happens automatically
490+
/// when calling `connect(transport:)`. You should use that method instead.
491+
///
492+
/// - Returns: The server's initialization response containing capabilities and server info
493+
@available(
494+
*, deprecated,
495+
message:
496+
"Initialization now happens automatically during connect. Use connect(transport:) instead."
497+
)
488498
public func initialize() async throws -> Initialize.Result {
499+
return try await _initialize()
500+
}
501+
502+
/// Internal initialization implementation
503+
private func _initialize() async throws -> Initialize.Result {
489504
let request = Initialize.request(
490505
.init(
491506
protocolVersion: Version.latest,

0 commit comments

Comments
 (0)