Sounds quite a bit like The Legion of Space by Jack Williamson. As I recall, the secret weapon (AKKA) was mostly mental so the physical portion of the device was really simple.
The Legion is the military and police force of the Solar System. It was created to keep the peace after the overthrow of the "Purples", a dynasty that ruled all humanity for generations. John Ulnar, a young graduate of the Legion academy, shares a surname with the Purples but is an enthusiastic supporter of the Legion.
A weapon called AKKA was used to defeat the Purples. Using a space/time distortion, it erases matter from the Universe—any matter, of any size, even a star or a planet. The secret of AKKA is kept in one family, descended from its creator, and is passed down from mother to daughter. One of the Legion's most important tasks is to guard the current Keeper, a beautiful young woman named Aladoree Anthar.
Through the machinations of his uncle, a powerful politician with a hidden agenda, John Ulnar is assigned to Aladoree's guard force at a secret fort on Mars. When she is kidnapped by a huge alien spaceship, John and the three other survivors of the guard force follow her kidnappers to a planet of Barnard's Star. They crash-land and must battle their way across a savage continent to the sole remaining citadel of the Medusae.
John Ulnar's uncle and his nephew have allied with the Medusae as a means to regain their empire, and have kidnapped Aladoree to ensure that AKKA is not used against them. The Medusae, however, turn on the Purples, seeking to destroy all humans and move to the Solar System, as their own world, far older than Earth, is spiraling into Barnard's Star.
John Ulnar and his companions rescue Aladoree, but the invasion of the Solar System has already begun. The Medusae conquer the Moon, set up bases there, and bombard Earth with gas projectiles. John, Aladoree, and their companions land on a ravaged Earth. Fighting off cannibals maddened by the gas, they build AKKA and destroy the Medusae fleets (and Earth's Moon as well).
In the fifth chapter, they need to build the AKKA, but are missing one essential component to finish it, something that is not among the materials available on that world, a piece of iron. They frequently refer to the old story of "for the want of a nail". In the sixth chapter, they return to Earth, and the bit of iron is found.
.... It was a child's toy that caught his eye. A rusty, broken little engine, that could no longer move its tiny burden—but might yet save the system.
He tore the shaft out of it, assured himself that it was iron, hastened back toward the cruiser.