The rules about becoming an MP are less restrictive to those that apply to standing for election as a local councillor.
Under the Representation of the People Act 1981, you are disqualified from becoming a member of the House of Commons if you have been found guilty of an offence and sentenced to more than one year in prison, and are currently detained as a result of that offence.
Once you are released from prison, you are not prevented from standing for election as an MP.
Technically, you are also able to stand for election while you are in prison, so long as the sentence is one year or less.
Other relevant pages on this site
If you’re looking to stand for election as a local councillor, different rules apply.