start method

Future<void> start()

Start the MCP server

Begins listening for incoming requests and processing them

Implementation

Future<void> start() async {
  if (_running) {
    _logger.warning('Server already running');
    return;
  }

  _logger.info('Starting ${_config.name} v${_config.version}...');
  _running = true;

  await _transport.start();
  _logger.debug('Transport started');

  // Listen for incoming requests
  _requestSubscription = _transport.requestStream.listen(
    _handleRequest,
    onError: (error) {
      _logger.error('Request handling error: $error');
    },
    cancelOnError: false,
  );

  _logger.info('Server started with ${_toolRegistry.count} tools, ${_resourceRegistry.count} resources, ${_promptRegistry.count} prompts');
}