diff --git a/Sources/MCP/Client/Client.swift b/Sources/MCP/Client/Client.swift index 696ffd14..a2deb3dc 100644 --- a/Sources/MCP/Client/Client.swift +++ b/Sources/MCP/Client/Client.swift @@ -272,8 +272,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 6ba1e27b..f2c975af 100644 --- a/Sources/MCP/Server/Server.swift +++ b/Sources/MCP/Server/Server.swift @@ -276,8 +276,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 }