Mets pitcher Matt Harvey couldn’t pinpoint precisely what was wrong, only that his mechanics were off and that his prized right arm had felt heavy since spring training.

That began to change Monday. That’s when Scott Boras, his agent, said Harvey began to feel a tingling sensation in his fingers.

Four days later, Boras confirmed that shortly after being diagnosed with the condition thoracic outlet syndrome, Harvey has chosen to undergo season-ending surgery.

The Mets also announced in a media release Friday afternoon that Harvey will have surgery and miss the remainder of the season.

“I’m extremely disappointed to learn that I’ll be out for the season,” Harvey tweeted. “But I’m relieved to have answers and get back to doing what I love.”

Boras said it was TOS — or the fallout from the compression of nerves in the shoulder — that caused what has been a lost season for Harvey. “Matt’s kind of felt like he had something,” said Boras, who traced the issue back to spring training. “He couldn’t put his finger on it. It was an irregularity, a heavy arm, not getting his arm slot where he wanted to get it. But the tingling in the fingers really gave us a diagnostic that led to ‘wait a minute, maybe he might have some sort of an issue.’ We sent him to the TOS specialist and sure enough, he tested positive for it.”

Surgery will be performed by Dr. Robert Thompson, the St. Louis-based specialist who confirmed the diagnosis Thursday.

“Terry [Collins] and I met with Matt today, and although we all feel badly for him, we expressed our support in this decision and know he will work as hard as possible to get back on the field for the 2017 season,” general manager Sandy Alderson said in a statement Friday.

Friday night’s game brought a fresh set of concerns: Yoenis Cespedes (strained right quad) and Noah Syndergaard (arm fatigue) both left with health issues.

Harvey, 27, is expected to be ready for next spring training. But he ends the season 4-10 with a 4.86 ERA in 17 starts and is leaving the Mets during their quest to return to the World Series.

It is the first time in his career that Harvey has lost double-digit games, and this season’s ERA is nearly double his previous career mark of 2.53. But beginning in spring training, Harvey battled issues with his velocity and later his command, attributes that had made him one of the best pitchers in baseball.

“Obviously, his initial thought was this is mechanical, I’ll just work it out, gut it out,” Boras said.

Mets officials, including Alderson, insisted that Harvey never raised any physical concerns about his arm until after his last start Monday, when he allowed six runs against the Marlins.

“It’s very comforting in a sense because we now know why the inconsistency of his command was what it was in ’16,” Boras said of the diagnosis. “We know it’s been irregular. As an athlete, when your nerves are impacted, obviously you’re not feeling the same. You don’t have the same sensory feel for how you control your mechanics.”

The procedure for TOS involves the removal of a rib to eliminate compression of nerves or blood vessels. In Harvey’s case, surgery will relieve nerve pressure that led to problems with his sense of feel.

“He’s optimistic, he’s disappointed,” Collins said. “He didn’t make any excuses for anything. He didn’t say, ‘Well, jeez, this was the reason I had a bad . . . ’ He didn’t, which is Matt Harvey. He’s never going to say that.”

There are a wide range of outcomes when it comes to pitchers and TOS. Some (Kenny Rogers and Josh Beckett) have come back after the procedure. Others (Noah Lowry and Jeremy Bonderman) have not. Boras expressed confidence that Harvey will bounce back, just as he did from Tommy John surgery.

“This is not a shoulder, this is not an elbow, it’s not a ligament, it’s not damage to the tissue of the shoulder,” Boras said. “They remove a rib, they create more space, so that the muscles don’t entrap the nerve and he has normal feeling on his release point, normal feeling on where his arm is. This is far less concerning than Tommy John.”

Though Harvey could have chosen to keep pitching with alternative treatments and delay the procedure until the offseason, Alderson said Thursday that surgery was “inevitable.”

Harvey logged 216 total innings last season, his first since Tommy John surgery. He had not previously thrown more than 200 innings in a season.

Alderson flatly dismissed any link between last year’s workload and Harvey’s diagnosis of TOS. Boras did not say there was a correlation, though he stopped short of ruling out the possibility.

“The only thing I can say is Matt is different in ’16 than he was in ’15, and this [TOS] condition has been diagnosed,” Boras said. “You can’t make concrete conclusions other than that.”