sendLoggingMessage

Future<Result<void, String>> sendLoggingMessage(

  1. LoggingMessageParams params, {
  2. String? sessionId,
})

Send logging message to client.

Implementation

Future<Result<void, String>> sendLoggingMessage(
  LoggingMessageParams params, {
  String? sessionId,
}) async {
  try {
    final jsParams = _loggingMessageParamsToJs(params);
    final sendFn = _mcpServer['sendLoggingMessage'] as JSFunction;
    final promise = sessionId != null
        ? sendFn.callAsFunction(_mcpServer, jsParams, sessionId.toJS)
              as JSPromise
        : sendFn.callAsFunction(_mcpServer, jsParams) as JSPromise;
    await promise.toDart;
    return const Success(null);
  } catch (e) {
    return Error('Failed to send logging message: $e');
  }
}