Run a job only on branch main only from merge requests (not direct commits)

Is it possible to trigger a job only on the branch main but only from merges but not a direct commits to the main?
In addition, is it to get the merge_request_id / the closes issue linked to that merge request?