The protagonist is a boy named Rob Joslyn. His age is not specified. Baum dedicated the book "To My Son, Robert Stanton Baum," who was born in 1886 and would thus have been about fifteen at the time it was published.
Rob is an electrical experimenter whose father encourages him and sees that he "never lacked batteries, motors or supplies of any sort." A "net-work[sic] of wires soon ran throughout the house". He loses track of the elaborately interconnected wires, and trying to get a cardboard house to light up, he "experimented in a rather haphazard fashion, connecting this and that wire blindly and by guesswork, in the hope that he would strike the right combination." There is a bright flash, and a being who calls himself the Demon of Electricity appears. He tells Rob that he has accidentally "touched the Master Key of Electricity" and is entitled "to demand from me three gifts each week for three successive weeks." Rob protests that he does not know what to ask for, and the Demon agrees to select the gifts himself.
During the first week, the Demon gives Rob three gifts:
a silver box of food tablets, each one of which provides sufficient nourishment for a whole day
a "small tube" which can direct "an electric current" at a foe, rendering him unconscious for the period of one hour
a wristwatch-sized transportation device, which allows the wearer to fly at any height and travel at high speeds in any direction, when it is working properly. It is, however, somewhat fragile and becomes damaged and unreliable during Rob's adventures, creating predicaments for him.
During the second week, the Demon gives Rob three additional gifts:
a "garment of protection," which renders him invulnerable to bullets, swords, or other physical attack
a "record of events," which provides remote views of important events taking place in any part of the world at any time within the last twenty-four hours
A "character marker," a set of spectacles: "while you wear them every one you meet will be marked upon the forehead with a letter indicating his or her character. The good will bear the letter 'G,' the evil the letter 'E.' The wise will be marked with a 'W' and the foolish with an 'F.' The kind will show a 'K' upon their foreheads and the cruel a letter 'C.'"
Over the next two weeks, Rob experiences adventures exploring the use of the Demon's gifts, but eventually concludes that neither he nor the world is ready for them. On the third week, Rob rejects the Demon's gifts and tells him to bide his time until humankind knows how to use them. The Demon leaves. With a light heart, Rob concludes that he made the right decision.
Like some of Baum's adult novels, The Master Key features encounters with real historical figures of the period, such as King Edward of Britain, President Loubet of France, and the Duke of OrlĂŠans.

Question: What does the demon do?
Answer: Grants Rob wishes.
Alternative answer: Give gifts to Rob