diff --git a/Sources/MCP/Client/Client.swift b/Sources/MCP/Client/Client.swift index 57485ade..bd939a43 100644 --- a/Sources/MCP/Client/Client.swift +++ b/Sources/MCP/Client/Client.swift @@ -332,8 +332,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 99fbe5cb..8ec858a2 100644 --- a/Sources/MCP/Server/Server.swift +++ b/Sources/MCP/Server/Server.swift @@ -327,8 +327,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 }