Kodai Senga has certainly taken to the Mets’ closer role, improving this week to 7-for-7 in save opportunities.

But the job might not be his for much longer.

Devin Williams threw a bullpen session Tuesday, marking his first time throwing from the mound since landing on the injured list on Aug. 10 due to a right shoulder strain.

The Mets remain hopeful Williams, 31, will be activated before the season ends.

“We’ll evaluate where he’s at and make a determination of what his next step looks like,” interim manager Andy Green said Tuesday in Miami, per SNY. “And as long as he tends to move in the right direction, we’re still optimistic that there are some outings before the year is over.”

Williams is 3-2 with a 4.66 ERA this season — his first with the Mets — but he has converted 16-of-19 save opportunities and boasts 51 strikeouts in 38.2 innings.

There’s no guarantee a healthy Williams would reclaim the closer role down the stretch, especially if the Mets opt to ease him back into action as they play out the schedule.

But Wiliams remains a significant piece of the Mets’ bullpen moving forward, as he has two years after this one remaining on his three-year, $51 million contract.

“I don’t think [we] as an organization are going to carry any doubt if he doesn’t pitch before the year’s over,” Green said. “I think it’s something he wants, and we want if he’s healthy, but it’s not something we would push to if [we] felt like we were putting him in any jeopardy for next year.

“I think he’s got a long enough track record to have some confidence that, regardless if he throws an inning, or two, or four before this year’s over, we’ve got confidence that he’s going to be fine.”

There is less certainty about Senga’s role going into next season, which will mark the final year on the 33-year-old right-hander’s five-year, $75 million contract.

A starter by trade, Senga has struggled with injury and inconsistency over the past three seasons, including going 0-7 with a 9.66 ERA in eight starts this season.

But Senga has flourished since moving last month into a high-leverage relief role, which has allowed him to narrow his arsenal to his two best pitches: an upper-90s fastball and a swing-and-miss “ghost” forkball.

In Tuesday night’s 7-5 win, Senga nailed down the save by throwing 10 consecutive forkballs to strike out the Marlins’ Owen Caissie and Kyle Stowers.

“They were very aggressive all day long,” Green said afterward.

“Anything you threw in the zone, they were taking a hack at, so it was more capitalizing on their aggression at that point in time. Senga did a really nice job changing the flow of the inning and getting us off the field with a win.”

Entering Wednesday night’s series finale at LoanDepot Park, Senga owned a sterling 2.03 ERA with 15 strikeouts in 13.1 innings over 14 appearances since the start of August. None of those outings were for more than one inning.

Similarly, Senga’s bullpen entrance to Michael Jackson’s “Beat It” has energized Mets fans during a losing season. Citi Field leaned into it by debuting a scoreboard video to accompany Senga’s entrance while Mr. Met delights with MJ-inspired dance moves.

Even if future ninth innings belong to Williams — a two-time National League Reliever of the Year with the Milwaukee Brewers — Senga could be a factor next season out of a Mets bullpen that recently traded away leverage relievers such as Luke Weaver and Huascar Brazobán.

“It’s fun to see,” David Stearns, the Mets’ president of baseball operations, said recently of Senga.

“I think he’d prefer to start, but his investment in that role and the way he’s embraced that role is a great example for his teammates, for the organization as a whole, and he’s done a great job.”