Sufyan bin ‘Uyaynah said to ‘Amr bin Dinar: Did you hear from Sayyiduna Jabir bin ‘Abdullah (may Allah be pleased with them both) that a man came to the Prophet’s Mosque carrying arrows, and the Messenger of Allah (peace and blessings be upon him) said to him: “Keep their tips covered?” He said: Yes.
Hadith Referenceسنن دارمي / من كتاب الصللاة / 1440
It is established from this hadith that one should not walk in the mosque carrying arrows or similar items, lest they strike someone. By analogy, it is also not permissible to enter the mosque carrying other weapons such as knives, daggers, swords, pistols, spears, or guns, or any uncovered sharp object.