If one were to open the Shulhan Arukh on the topic of saying the ברכת המזון (grace after meals) with a cup (for instance, see Berakhos 51a), one would find that Rabbi Yosef Karo wrote the following (OH 182.1):
יש שאומרים שברכת המזון טעונה כוס אפילו ביחיד, וצריך לחזור עליו, ולא יאכל אם אין לו כוס לברך עליו אם הוא מצפה ואפשר שיהיה לו, אפילו אם צריך לעבור זמן אכילה אחת; ולפי זה אם שנים אוכלים יחד צריך לקחת כל אחד כוס לברכת המזון; וי"א שאינה טעונה כוס אלא בשלשה; ויש אומרים שאינה טעונה כוס כלל, אפילו בשלשה
There are some that say that the grace after meals requires a cup, even for an individual, and he needs to go over it, and he shouldn’t eat if he has no cup over which to bless upon it if he is looking and it is possible that it should be for him, even if he needs to go past one eating time. And according to this, if there are two eating together, each one needs to take a cup for the grace after meals.
There are some who say that a cup is required only for three.
There are some who say that there is no need for a cup at all, even with three.
Rabbi Moshe Isserles added the following to it:
הגה: ומ"מ מצוה (ד) מן המובחר לברך על הכוס
In any event, it’s a preferable way of performing the commandment to bless over a cup.
There’s a lot there, but how’d it get to this?
There is nothing explicit in tannaitic texts, but there are two of them that later sages saw that there was something implicit in them – a mishnah in the tenth chapter of Pesahim (found in the Bavli on 117b) and a tosefta in the fifth chapter of Berakhos (this tosefta is found three times within the text of the Bavli – in Berakhos 52a, Pesahim 102b & 105b):
מזגו לו כוס שלישי מברך על מזונו ….
They mix for him a third cup – he blesses over his food…
הנכנס לביתו במוצאי שבת - מברך על היין ועל המאור ועל הבשמים ואחר כך אומר הבדלה, ואם אין לו אלא כוס אחד - מניחו לאחר המזון ומשלשלן כולן לאחריו
One who enters into his house upon the sabbath’s departure – he should bless over the wine, and over the light, and over the spices, and after that, say the separation prayer. And if he only has one cup, he should place it for after the meal and include all of them afterwards.
From the mishnah, Rav Hanan (in the Vilna printed edition) said to Rava that one can infer that the grace after meals requires a cup, whereupon Rava replied to him that the four cups the rabbis instituted out of the way of freedom (Pesahim 117b).
On Pesahim 105b, one of the redactors said that from the Tosefta, one requires a cup over the grace after meals.
From these two aforementioned Talmudic texts, the medieval commentators then develop the issue.
However, Tosafos (Pes. 105b, s.v. Shema’ minah berakhah t’eunah cos) suggests that the halakhah is that it does require a cup (while mentioning that there is a custom of three blessing over a cup), even for an individual(!). (The Rosh (on Pes 105b) while offering a suggestion that goes against Tosafos’ reading of the individual language of the tosefta, he ends up bringing Rabbi Yehiel from Paris suggesting that a cup is necessary.)