Skip to content

Commit cdaca38

Browse files
docs(core): note params normalization to {} in setCustom* handlers
1 parent b52bc34 commit cdaca38

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/core/src/shared/protocol.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,9 @@ export abstract class Protocol<ContextT extends BaseContext> {
10671067
* string and validates incoming params against a user-provided schema instead of an SDK-defined
10681068
* one. Capability checks are skipped. The handler receives the same {@linkcode BaseContext | context}
10691069
* as standard handlers, including cancellation, task support, and bidirectional send/notify.
1070+
*
1071+
* Absent or undefined `params` are normalized to `{}` (after stripping `_meta`) before
1072+
* validation, so for no-params methods use `z.object({})` rather than `z.undefined()`.
10701073
*/
10711074
setCustomRequestHandler<P extends AnySchema>(
10721075
method: string,
@@ -1104,6 +1107,9 @@ export abstract class Protocol<ContextT extends BaseContext> {
11041107
* Unlike {@linkcode Protocol.setNotificationHandler | setNotificationHandler}, this accepts any
11051108
* method string and validates incoming params against a user-provided schema instead of an
11061109
* SDK-defined one.
1110+
*
1111+
* Absent or undefined `params` are normalized to `{}` (after stripping `_meta`) before
1112+
* validation, so for no-params methods use `z.object({})` rather than `z.undefined()`.
11071113
*/
11081114
setCustomNotificationHandler<P extends AnySchema>(
11091115
method: string,

0 commit comments

Comments
 (0)