Send initialized notification from client instead of server (#85)
This commit is contained in:
parent
29aa74d137
commit
25dee3bb4c
1 changed files with 130 additions and 12 deletions
|
|
@ -249,6 +249,16 @@ public actor Client {
|
|||
return self
|
||||
}
|
||||
|
||||
/// Send a notification to the server
|
||||
public func notify<N: Notification>(_ notification: Message<N>) async throws {
|
||||
guard let connection = connection else {
|
||||
throw MCPError.internalError("Client connection not initialized")
|
||||
}
|
||||
|
||||
let notificationData = try encoder.encode(notification)
|
||||
try await connection.send(notificationData)
|
||||
}
|
||||
|
||||
// MARK: - Requests
|
||||
|
||||
/// Send a request and receive its response
|
||||
|
|
@ -454,6 +464,8 @@ public actor Client {
|
|||
self.serverVersion = result.protocolVersion
|
||||
self.instructions = result.instructions
|
||||
|
||||
try await notify(InitializedNotification.message())
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue