This paper proposes a novel multi-stage optimal economic dispatch algorithm for a seaport integrated with a DC microgrid to support the main grid while feeding local loads. In addition, a dynamic pricing profile has been generated to encourage the adoption of alternative maritime power (AMP) technology by both parties (seaports and ships). Optimum charging and discharging decisions for energy storage systems (ESSs) have been initiated based on real-time grid pricing integrated with battery energy level to develop a dynamic tariff profile. Moreover, two algorithms, a rule-based algorithm and the firefly algorithm (FA), have been used together to implement an optimized energy management system (EMS). The results demonstrated that the proposed EMS can effectively schedule ESS devices while considering the economic benefits of the system. To conduct the analysis, a seaport system connected to a 10 kV DC microgrid with two 1 MW AMPs has been considered. In addition, an optimization code has been developed using MATLAB functions, and a complete study has been performed using the MATLAB/Simulink platform. The results have shown a considerable saving in cost of about 24 -41 % by the proposed tariff profiles.INDEX TERMS Alternative maritime power (AMP), DC microgrid, energy management system, firefly algorithm (FA), multi-objective optimization, penalty function, rule-based optimization, seaport microgrid.