Why do I have mucus in stool and constipation when I drink coffee? Stopped drinking coffee for a week and mucus went away?

Laxative. Coffee often acts as a laxative but it is unusual to have mucus in the gut from drinking it. However if avoiding it solves the problem. that is the answer to your question.