The 81-year-old Arizona Republican was diagnosed with brain cancer in July last year.
He received chemotherapy and radiation treatment, and in December was treated at a military hospital outside Washington for side effects of cancer therapy.
"My husband @SenJohnMcCain is doing well after his surgery," McCain's wife Cindy said in Twitter post, adding that he was looking forward to getting back home.
The statement issued by the senator's office said McCain underwent surgery at Mayo Clinic in Phoenix to treat an intestinal infection related to diverticulitis.
"Over the last few months, Senator McCain has been participating in physical therapy at his home in Cornville, Arizona, as he recovers from the side effects of cancer treatment," the statement said.
McCain, who lost the 2008 U.S. presidential election to Barack Obama, is serving his sixth term as a senator.
(Reporting by Mohammad Zargham; Editing by Tom Brown)