onSamplingRequestMap method

void onSamplingRequestMap(
  1. Future<Map<String, dynamic>> handler(
    1. Map<String, dynamic> params
    )
)

Map-based variant of onSamplingRequest. Receives the spec CreateMessageRequest.params as a raw map and must return the raw CreateMessageResult map.

Exists so generic adapters (notably mcp_llm's LlmClientAdapter) can register a handler without importing the typed CreateMessageRequest / CreateMessageResult models — the typed entry point's signature would otherwise fail the runtime function subtype check at dynamic dispatch time.

Implementation

void onSamplingRequestMap(
  Future<Map<String, dynamic>> Function(Map<String, dynamic> params) handler,
) {
  _requestHandlers['sampling/createMessage'] = handler;
}