We investigate a heat engine with a finite-length Kitaev chain in an ideal Otto cycle. It is found that the critical point of the topological phase transition coincides with the maxima of the efficiency and work output of the total Otto engine. Finite-size effects are taken into account using the method of Hill's nanothermodynamics, as well as using the method of temperature-dependent energy levels. We identify the bulk and boundary thermal cycles of the Kitaev chain engine and find that they are nonideal Otto cycles. The physics of deviation from ideal Otto cycle is identified as a finite-size effect, which we dub as "internal geometric friction," leading to heat transfer from the bulk to the boundary during the adiabatic transformation of the whole system. In addition, we determine the regimes allowing for independently running an ideal Otto refrigerator at the boundary and ideal Otto engines in the bulk and in the whole system. Furthermore, we show that the first-order phase transition in the boundary and the second-order phase transition in the bulk can be identified through their respective contributions to the engine work output.