If only weight loss were as simple as taking a pill, right?

It’s a common refrain, one frequently exploited by those hawking shady diet pills, fat-burning supplements and get-fit-quick schemes online.

Before your skepticism hardens into concrete, consider this: An MIT researcher says his team has developed a sophisticated pill that could shrink the space inside your stomach, making it easier to avoid excess calories.

Though he doesn’t offer a money-back guarantee, Xuanhe Zhao — an associate professor of mechanical engineering at MIT — is part of a team that has developed a pill that swells to the size of a golf ball after it’s ingested and could remain inside the stomach for as long as a month.

The pill is still being tested in models resembling the human gastrointestinal tract, but researchers hope to commercialize the technology one day.

“The idea is, you would eat a few of these pills; they would swell in the stomach and occupy it with very soft materials to make people feel full and eat less,” Zhao said. “It’s simpler than surgery or putting painful rubber balloons in someone’s stomach to make themselves eat less.”

For those in dire need of extreme weight loss, the options can seem daunting and invasive. Surgeries such as gastric bypass and sleeve gastrectomy reduce the size of the stomach — decreasing the number of calories the body can absorb — but are irreversible and carry frightening risks, such as blot clots and infection.

The appeal of the expanding pill is its simplicity, Zhao said. The pill is made from two types of hydrogels — mixtures of polymers and water. Once swollen, Zhao said, the pill has a consistency similar to tofu or jello.

To remove the objects from the stomach, he said, a patient would drink a calcium solution (at a concentration higher than what’s in milk) that would shrink the pills to their original size, allowing them to pass through the digestive system.

Zhao said weight loss is one potential application for the technology, but there are others. For years, he said, researchers have been trying to develop a pill capable of remaining inside the human body for weeks or even months — a branch of research known as “ingestible electronics.” The challenge, he said, has been engineering a pill small enough to be taken orally, but tough enough to endure the perilous environment inside the human stomach, with its muscular squeezing and acidic juices.

“We really needed a pill to swell up fast enough before the stomach empties itself,” said Zhao, noting the pill’s design was inspired by the puffer fish, which quickly sucks in water to inflate its size and avoid predators.

However improbable sounding, such a pill would allow doctors to monitor conditions inside the body such as Ph balance, viruses, bacteria or temperature. Researchers say the pills could also be used to place tiny cameras inside the body that could monitor tumors and ulcers over time. Sensors embedded in the pill could monitor whether a patient was taking medications on schedule.

Not taking medicine — or “medication nonadherence” in the health-care world — is a “common and costly problem,” according to a study cited by the National Center for Biotechnology Information.

“Approximately 30 percent to 50 percent of U.S. adults are not adherent to long-term medications, leading to an estimated $100 billion in preventable costs annually,” according to the 2013 study.

Monitoring a patient from the inside may sound futuristic, but it’s already taking place.

At the Masonic Cancer Clinic at the University of Minnesota, doctors are embedding tiny sensors in pills that allow them to keep tabs on chemotherapy patients' heart rate, activity level and sleep cycle. The sensor, which is about the size of a grain of sand and dissolves in the gastrointestinal tract, also tells doctors when a patient has ingested medication. The information is compiled in a database that doctors can access from their devices.

“I had one patient whose hands hurt and she couldn’t open her pill bottle,” said physician Edward Greeno, noting that when the patient’s daughter was around, she would take her pills, but when her daughter was gone, she wouldn’t. “The app is telling me in real time that she didn’t take her pills, and I get that message in clinic the next morning.”