diff --git a/Sources/MCP/Client/Client.swift b/Sources/MCP/Client/Client.swift index f6ec77a..e240665 100644 --- a/Sources/MCP/Client/Client.swift +++ b/Sources/MCP/Client/Client.swift @@ -244,8 +244,7 @@ public actor Client { _ type: N.Type, handler: @escaping @Sendable (Message) async throws -> Void ) async -> Self { - let handlers = notificationHandlers[N.name, default: []] - notificationHandlers[N.name] = handlers + [TypedNotificationHandler(handler)] + notificationHandlers[N.name, default: []].append(TypedNotificationHandler(handler)) return self } diff --git a/Sources/MCP/Server/Server.swift b/Sources/MCP/Server/Server.swift index 15ad3db..077103f 100644 --- a/Sources/MCP/Server/Server.swift +++ b/Sources/MCP/Server/Server.swift @@ -257,8 +257,7 @@ public actor Server { _ type: N.Type, handler: @escaping @Sendable (Message) async throws -> Void ) -> Self { - let handlers = notificationHandlers[N.name, default: []] - notificationHandlers[N.name] = handlers + [TypedNotificationHandler(handler)] + notificationHandlers[N.name, default: []].append(TypedNotificationHandler(handler)) return self }