Born in Bucks County, Pennsylvania, he taught school and worked as principal of Loller Academy in Hatboro, Pennsylvania in 1825. He established a boys school in the village of Abington, Pennsylvania. He served as clerk of the courts of Montgomery County, Pennsylvania from 1845 to 1848 and moved to Norristown, Pennsylvania.
McNair was elected as a Democrat to the Thirty-second and Thirty-third Congresses. He served as chairman of the United States House Committee on Manufactures during the Thirty-third Congress. McNair settled on a plantation in Prince William County, Virginia, near Gainesville.