Hello and welcome to e health forum.
It is not possible to know the exact cause of your problem from the given history.
But presence of mucus, in the stools could be due to conditions including malabsorption, parasitic infections, inflammatory bowel disorder, irritable bowel syndrome, etc.
Additional medical history, a complete physical examination and a stool examination would help to know the exact cause of your condition.
You might consult your doctor for a proper examination and further advice.
I hope this helps.