  The goal of this study is to check which, if any, of the published versions
of the pion and kaon fragmentation functions is compatible with the STAR data
on semi-inclusive pion and kaon production in proton-proton collisions, and on
the basis of this analysis to make reliable predictions for the $p_T$ spectra
of the pions and kaons in inclusive pion and kaon production at the future NICA
proton-proton collider. The calculations are carried out in next-to-leading
order (NLO) of perturbative quantum chromodynamics (pQCD), using the well
tested CTEQ6 parton distributions. We consider the following pion and kaon
fragmentation functions (FFs) -- DSEHS-14, DSEHS-17, LSS-15, HKNS-07 and
AKK-08. Our analysis shows that within the experimental errors all tested sets
of fragmentation functions provide a good fit to STAR data at the c.m. energy $
\sqrt{S} = 200\, {\rm GeV} $, and the best ones are both LSS-15 and DSEHS-14
for pions and DSEHS-17 for kaons. From comparison of the LO and NLO results it
is clear that the latter fit data much better, specially in the region of small
$p_T$. The NLO cross sections are also less scale-$Q^2$ dependent, where
$p_T/2\leqslant Q \leqslant 2p_T$, than the LO ones. In order to make
predictions for NICA energies, we compare the NLO pQCD results with the
existing experimental BES STAR data on semi-inclusive hadron production in the
most peripheral Au+Au collisions where the nuclear effects can be neglected.
The comparison for lower energy scales, like at NICA, shows that a purely pQCD
approach is inadequate and suggests the necessity to take into account also
higher-order effects of initial-state soft-gluon radiation. Nevertheless, these
data on the $p_T$ spectra of $\pi^+$, $K^+$ and also the ratios $\pi^-/\pi^+$
and $K^-/K^+$ seem favour LSS-15 and DSEHS-14 FFs for pions and DSEHS-17 for
kaons, similarly as at the energy scale $ \sqrt{S} = 200\, {\rm GeV} $.
