Few historical figures are as sexy to modern academics as the legendary abolitionist John Brown. Brown, who looked and talked like a biblical prophet, who claimed to commune with God and who brutally murdered many, who attempted to foment a slave uprising in Virginia and ended up swinging from a hangman’s noose, who did more than almost any other person to spark the Civil War, was a complex and heroic and tragic and endlessly fascinating figure. Some historians consider him a shining beacon of compassion, others a monomaniacal lunatic.

Nor is Brown new to American fiction. Authors ranging from Herman Melville to Marilynne Robinson have taken a crack at Brown. But few have done so with the humor or the perceptiveness of James McBride in his latest novel, “The Good Lord Bird.”

McBride, a journalist and acclaimed jazz saxophonist, is best known for his 1995 memoir, “The Color of Water,” which describes the relationship between himself, the other members of his poor, black and biracial family, and his white, Jewish mother. “The Good Lord Bird” is likewise informed by knowledge of racial passing, interracial social dynamics and a deep understanding of the past. It is obviously inspired by Southern classics, such as “Huckleberry Finn” and “To Kill a Mockingbird.” Yet it also has an awareness of history that is all its own.

“The Good Lord Bird” tells the story of Henry Shackleford — a funny, lazy, 10-year-old slave when the book begins. Henry’s father is giving haircuts in a hole-in-the-wall saloon in frontier Kansas, when a talkative Irish stranger gets a little too fanatical with his evangelism. The Shacklefords’ owner bursts in, the Irish stranger drops his accent and he reveals himself to be the notorious outlaw John Brown. A gunfight breaks out. Henry’s father is killed, and Brown whisks Henry out of the saloon and off to freedom.

Because of Henry’s curly hair and delicate features, Brown mistakes him for a girl — Henrietta. Brown hands the understandably thunderstruck Henry a gnarly, old onion, which Henry quickly devours, hoping to make a good impression. Brown tells young Henrietta that the onion had actually been his good-luck charm — having resided in his pocket for more than a year. Now that it was inside of Henry, he would be Brown’s new good luck charm. Henry, or Henrietta, becomes “Little Onion,” or, more casually, just “Onion.”

Brown kindly provides Onion with a new dress and bonnet, and Brown’s ragtag army of followers — including several of his 21 children — quickly adopt Onion as a mascot and beloved compatriot. Onion is decidedly less comfortable with Brown’s crew and often considers returning to the familiarity of slavery. Yet “she” remains.

Onion remains with Brown’s band until the eve of the infamous Pottawatomie Massacre, in which Brown’s men murder five pro-slavers in a single night, resulting in months of retaliatory raids. Onion gets separated from the men and ends up in a Kansas saloon and whorehouse. For two years, Onion just sweeps the floors and gets drunk a lot; the madam starts implying, however, that she — Onion — might soon have to start earning her keep.

Onion is rescued by one of Brown’s sons and rejoins the “Old Man.” She travels with Brown to Boston and Philadelphia, attending an abolitionist rally where “everybody got to make a speech about the Negro but the Negro.” Eventually, they rejoin Brown’s band and begin to make their way deep into slave country, toward death and immortality.

“The Good Lord Bird” is impressively accurate in many ways: the idioms of the characters, the realities of slavery and so many of the small details of Brown’s crusade. Yet McBride is willing to ignore reality for the sake of hilarity. At one point, Onion meets a bumbling and egotistical Frederick Douglass, who tries hard to sleep with her and ends up passing out, drunk. Earlier, confronted by a group of pro-slavery vigilantes, Onion evades capture by crying and saying, “I just don’t know where I belongs, being a tragic mulatto and all.”

Remarkably, though, so many of the hilarious details are accurate: Brown tries to team up with Harriet Tubman, whom he calls “General Tubman”; Brown often halts his army’s progress to loudly commune with God; Brown’s men eventually hold hostage a pompous nephew of George Washington.

Reviewer Hector Tobar joined so many of his colleagues when he likened “The Good Lord Bird” to “Huckleberry Finn.” Both novels feature endless humor and wisdom from the mouths of cheeky children. But to Tobar, “The Good Lord Bird” lacks the “humanity” of Huck Finn. I think this is ungenerous. Satire can be more powerful than elegy; fiction can zqbe more informative than hardcore history.

Little Onion, the cross-dressing, spit-shined narrator, is unafraid to see the evil and pettiness around her — in everyone from slaveholders to slaves themselves. Brown emerges a hero, but no one emerges unflawed. This is not a gilded portrait; it is reality. Irreverence, in the end, is a touching tribute to the icons of the past.