Melt the butter in a saucepan over moderate heat and saute the onion until tender but not brown, about 5 minutes. Add the grated potato, stock, and milk and bring to a boil, stirring occasionally. Simmer until the potato has cooked and dissolved into the mixture, 5 to 10 minutes. Add the cheese, salt, pepper, and cayenne. Stir until the cheese is melted.