Deductions & credits

First the sale of a personal residence may be excluded from US tax if you qualify :   https://journal.firsttuesday.us/excluding-profit-on-the-sale-of-a-foreign-home/26033/

 

Then, the closing costs are added to the cost basis to figure if there was a taxable gain.  

 

Lastly, only if the gain is taxable will you be able to use any part of the Mexico income tax as a deduction or a credit.