In the book of Tehillim (Psalms), Chapter 86, King David says the following:
שָֽׁמְרָ֣ה נַפְשִׁי֮ כִּֽי־חָסִ֪יד אָ֥נִי הוֹשַׁ֣ע עַ֭בְדְּךָ אַתָּ֣ה אֱלֹהַ֑י הַבּוֹטֵ֥חַ אֵלֶֽיךָ׃
Preserve my life, for I am steadfast; O You, my God, deliver Your servant who trusts in You. (Sefaria Translation)
The Talmud Berachos 4a clearly understands that, in this Tehillim, King David is praying to God and is asking for something based on his own merit/behavior.
However, The Maharal (Derech Chaim on Avos 2:13) says that a person should not pray and ask for something as if he deserves it. The Chasid Yaavetz says (Avos 2:13) a similar idea. The Sifri in the beginning of Parshas Va'Eschanan says that Moshe and David did not ask for things from Hashem because they deserved it, they asked for things for free, as it were. Other sources that echo this idea are Devarim Rabbah 2:1 and the Meiri on Berachos 10b.
So the question is, in light of all the sources mentioned, should a person pray to God and ask for things in their own merit or not?