Wilson McCarthy, 50, a congressional liaison officer and campaign advance man for presidents Kennedy and Johnson, died Friday at his home in Guelph, Ontario, following a heart attack.

Mr. McCarthy worked under Kenneth O'Donnell as an advance man during the 1960 presidential campaign of John F. Kennedy. After the election, he worked briefly for the Commerce Department and then joined R. Sargent Shriver and Bill Moyers in guiding legislation through Congress to establish the Peace Corps.

When the Peace Corps had been set up, Mr. McCarthy became a congressional liaison officer for the agency and an assistant to Moyers, then the assistant director of the Peace Corps. In the 1964 presidential campaign, he was the chief advance man for Lyndon B. Johnson.

A year later, Mr. McCarthy left the White House. He was a public relations executive and producer with MGM and Warner Brothers in Europe and California. In the early 1970s, he became a novelist, living first in Britain, and since 1974, in Canada.

His first novel, "The Detail," was published in Britain in 1973. It was a story about the White House Secret Service detail and an attempt on the life of a president. His subsequent work was in a similar vein. He was working on his third novel at the time of his death.

A native of Washington, Mr. McCarthy graduated from old Central High School and attended George Washington University. He was an Army infantryman during the Korean war. After working for a time for the Veterans of Foreign Wars, he joined the staff of Rep. Sam Rayburn (D-Tex.), then the speaker of the House of Representatives, and remained there until he went to work in Kennedy's presidential campaign.

Mr. McCarthy's survivors include his wife, the former Patricia Scherer, a daughter, Shealah, and two sons, Sean and Cormac, all of Guelph, another son, Michael, his mother, Constance McCarthy, and a sister, Constance Zarbo, all of Rockville.