onElicitationRequestTyped method
Typed variant of onElicitationRequest (spec 2025-11-25). The handler
receives a parsed ElicitationRequest — form fields typed as
ElicitationFieldSchema (strings/numbers/booleans with defaults,
single- and multi-select enums with enumNames), or a URL-mode request
(mode: "url") — and returns a typed ElicitationResponse.
This is a convenience over the raw-map path; the wire behavior is
identical. Registering either handler overrides the other (both bind
the same elicitation/create slot). Calling this advertises the
elicitation client capability.
Implementation
void onElicitationRequestTyped(
Future<ElicitationResponse> Function(ElicitationRequest request) handler,
) {
_requestHandlers['elicitation/create'] = (params) async {
final req = ElicitationRequest.fromJson(params);
final res = await handler(req);
return res.toJson();
};
}