SAN FRANCISCO — Even with Joe Panik back in the lineup and Matt Duffy two days from a rehab assignment, the Giants felt they needed help on the infield. Enter Eduardo Nunez, a versatile veteran who was acquired from the Minnesota Twins before Thursday night’s game. 

The Giants sent left-handed prospect Adalberto Mejia to Minnesota in exchange for Nunez, a 29-year-old who is hitting .296 this season with 12 homers and an American League-leading 27 stolen bases. Nunez will primarily back up Duffy and Panik, and he can fill in at shortstop, too. 

Before the deal was announced, general manager Bobby Evans met with Duffy to assure the young third baseman that he is not being replaced after spending over a month on the disabled list with an Achilles strain. When Duffy does return, likely sometime in the next couple weeks, the Giants will build in additional off days to make sure he stays healthy. 

“We’ve seen the need for depth in the infield,” Evans said.

[PAVLOVIC: Giants acquire Nunez from Twins for Mejia]

The group will undergo further changes on the next road trip. Ehire Adrianza is expected to return in Philadelphia on Tuesday after missing the past 92 games with a fractured foot. Adrianza was batting .346 with six homers entering a rehab game Thursday. 

Hunter Pence is also expected back Saturday, meaning three players from the current roster will either be sent down or designated for assignment over the coming days. Grant Green was DFA’d earlier Thursday to clear a roster spot for Panik.

Evans said the front office remains focused on adding a bullpen arm, but the opportunity was there to acquire Nunez and the Giants pounced. Originally signed by the Yankees in 2004, Nunez, who bats right-handed, has spent the past three seasons with the Twins. He is not a free agent until after the 2017 season. 

“He’ll be used as we would use any utility infielder,” Evans said. “He’ll help with his speed and experience and bat, and it gives us some versatility and flexibility.”

Nunez has spent most of his time at shortstop this season, getting 48 starts there, along with 28 at third and four at second base. To add him, the Giants gave up a pitcher they think highly of. 

Mejia is a big 23-year-old is 7-3 with a 2.81 ERA in 18 starts at Double-A and Triple-A this season. In trade discussions over the past month, his name has come up often.

“To see him go is hard,” Evans said. “He took it well and is excited for the next opportunity. We knew we would be asked for some heavy costs. It wasn’t a surprise he was asked about quite a bit.”

Even with Mejia gone, Evans said he’s confident the Giants have enough in their system to find pitching help if the right opportunity presents itself.