The moment generating function of X is the function of t given by the expectation of . Expanded as a power series in t, the coefficient of is where is the r-th moment.
So the expectation of X, which is , is the coefficient of t in or alternatively .
To recover X we see that the random variable which takes values 1, 2, 3 with probabilities 1/6, 1/3, 1/2 respectively has the required MGF.
There's a good article in MathWorld.