startServer method

Future<void> startServer()

Starts the MCP server if not already running

⚠️ Security: Server will only start if enabled for mobile/web platforms.

Implementation

Future<void> startServer() async {
  // Security check: Don't start server in mobile/web unless explicitly enabled
  if (!_enableInMobile && (kIsWeb || Platform.isAndroid || Platform.isIOS)) {
    developer.log(
      '⚠️ MCP Server start blocked: Not enabled for mobile/web. '
      'Set enableInMobile: true to allow (security risk!).',
      name: 'MCPLogStrategy',
    );
    return;
  }

  if (!_mcpServer.isRunning) {
    await _mcpServer.start(apiKey: _apiKey);
  }
}