CBS Studios has cast two key roles in its miniseries that will be based on a book by ousted FBI Director James Comey.

Jeff Daniels will play the embattled Comey in the four-part series, while Brendan Gleeson (“Mr. Mercedes”) will portray President Donald Trump, who fired Comey in May 2017.

The four-parter’s backstory comes from Comey’s April 2018 book, “A Higher Loyalty: Truth, Lies, and Leadership,” which documents his two decades of government work, including the 2013-2017 period when he was FBI director under presidents Barack Obama and Trump.

The project — from Alex Kurtzman’s (“Star Trek: Discovery”) production company Secret Hideout and Shane Salerno’s the Story Factory — will begin filming next month and may find a home on CBS Corp.’s Showtime or its CBS All Access streaming service, according to The Wrap.

The series is written by Billy Ray (“Captain Phillips”), who called Daniels “perfect” for the role.

“Great actor, instant integrity, loads of warmth, intelligence, complexity and gravitas,” Ray tells TV Line. “We talked backstage after I saw him in ‘To Kill a Mockingbird’ on Broadway, and I knew I was looking at the only person who could play Jim Comey. Lucky for me, he said yes.”

Ray also praised Gleeson’s selection to embody Trump.

“It’s hard to imagine a bigger acting challenge than playing Donald Trump,” he tells The Wrap. “You have to have presence and a singular kind of dynamism. You also have to have the courage and the will to play Trump’s psychology from the inside out.”

Daniels was nominated for his third Tony Award this year for Best Actor in a Play for his performance as Atticus Finch in “Mockingbird,” an adaption of the Harper Lee novel. He leaves the role Nov. 3 and will be replaced by “Westworld” star Ed Harris.