ping method

Future<void> ping({
  1. Map<String, dynamic>? meta,
  2. RequestOptions? options,
})

Sends ping and completes when the peer answers.

The result is empty by definition; this is a liveness probe, so the value is that it returned at all. 2026-07-28 has no ping: refused here (-32601) rather than asked of a server that cannot answer it.

Implementation

Future<void> ping({Map<String, dynamic>? meta, RequestOptions? options}) async {
  if (!_initialized) {
    throw McpError('Client is not initialized');
  }
  if (_statelessMode) {
    throw McpError('ping is not part of protocol ${McpProtocol.v2026_07_28}',
        code: McpProtocol.errorMethodNotFound);
  }
  await _sendRequest('ping', _withMeta(const {}, meta), options);
}