notify<M extends ClientNotificationMethod>(
params: ClientNotificationParams<M>,
): void {
// `params` may be `undefined` (e.g. `initialized` carries no
// payload). Don't include the key in that case.
const payload: { method: string; params?: unknown } = { method };
if (params !== undefined) {
payload.params = params;
}
}
onNotification<M extends ServerNotificationMethod>(