Your sentence is almost correct. However, there's a small mistake in it. "Kaffe" should be corrected to "Kaffee", and "zu" should be replaced with "zum". Here's the corrected sentence: "Ich kaufe Kaffee zum Mitnehmen." In German, "zum" is a contraction of "zu dem," which means "to the" or "for the" in English. In summary, "zum" is used because "Mitnehmen" is neuter. If it were a feminine noun, we would use "zur." To note - Zu comes with a dative.