Could you supply your full code, with 3x` encapsulation, as currently the indentation is wrong, and the code ends at finalizing the MPC, not at the end of solve.
To me, it also seems like you are importing things that are not needed, such as
The following is unused:
and I would be careful with:
as those should be from your MPC space, as discussed in: