Coffee grounds attract organisms in the ground, like worms, that are very beneficial, i.e. outdoor soil critters.
I would not use them in potting soil indoors as what makes them work so well outdoors is missing.
I used to store my coffee grounds all winter in cans and pots.
they were moldy and nasty smelling in spring but I would put them in the hole with potatoes.
I would notice that when I dug up the potatoes, the area where I planted was a very fine soft soil.
I often thought of going to coffee shops and getting their grounds for potato planting but my yield have been good enough I just now just dump them in pile in the garden in winter and roto-till them in in spring but they would make a great addition to a compost heap as I do in summer.