With the proliferation of services and the vast amount of data produced by the Internet, numerous services with comparable functionalities but varying Quality of Service (QoS) attributes are potential candidates for meeting user needs. Consequently, the selection of the most suitable services has become increasingly challenging. To address this issue, a synthesis of multiple services is conducted through a composition process to create more sophisticated services. In recent years, there has been a growing interest in QoS uncertainty, given its potential impact on determining an optimal composite service, where each service is characterized by multiple QoS properties (e.g., response time and cost) that are frequently subject to change primarily due to environmental factors. Here, we introduce a novel approach that depends on the Multi-Agent Whale Optimization Algorithm (MA-WOA) for web service composition problem. Our proposed algorithm utilizes a multi-agent system for the representation and control of potential services, utilizing MA-WOA to identify the optimal composition that meets the user’s requirements. It accounts for multiple quality factors and employs a weighted aggregation function to combine them into a cohesive fitness function. The efficiency of the suggested method is evaluated using a real and artificial web service composition dataset (comprising a total of 52,000 web services), with results indicating its superiority over other state-of-the-art methods in terms of composition quality and computational effectiveness. Therefore, the proposed strategy presents a feasible and effective solution to the web service composition challenge, representing a significant advancement in the field of service-oriented computing.