In the French translation of Harry Potter a l'ecole des sorciers, the sentence “Make Harry get it!” (it being the post, i.e. letters) is translated as
Harry n'a qu'à y aller.
This seems to me to say something like “Harry has to go there” but that is a very loose translation and seems to ignore the n' and the à.
Is this simply an idiomatic expression that should be learned as a whole, like “Je pas” or can it be logically deciphered using the word meanings and the rules of grammar? If the latter I don't understand why the negative n' is there, or why the à is there, as the “to” with which I associate it is already contained in the y, at least in the sense of allons y.
If it is an indivisible idiomatic expression, what is its general form and meaning and in what circumstances would one use it? If it is standard grammar, how can I deconstruct it to achieve the intended meaning?