The documentation for coffee appears far later than that of either tea or cacao, and its consumption does not become commonplace until the 15th century in the Middle East.
Its mythical beginnings parallel tea and cacao. Abū al-Tayyib, a 10th-century Iranian poet, suggested that Solomon, the king of Israel in the 9th c. BCE, cured sickly inhabitants along his travels, after the angel Gabriel instructed him to give them roasted beans "from the Yemen." After that, it was forgotten for 2,000 years.
"At the beginning of this [the sixteenth] century, the news reached us in Egypt that a drink, called qahwa, had spread in the Yemen and was being used by Sufi shaykhs [sheikhs] and others to help them stay awake during their devotional exercises, which they perform according to their well-known Way...
When Sufi Jamāl al-Dīn Abū 'Abd Allāh Muhaammad ibn Sa'īd... [fell ill] he drank [qahwa] and benefited by it. He found that among its properties was that it drove away fatigue and lethargy, and brought to the body a certain sprightliness and vigor. In consequence, when he became a Sufi, he and other Sufis in Aden [city in Yemen] began to use the beverage made from it." - S. de Sacy. Chrestomathie arabe. 2nd ed. Paris, 1826.