McCarthy (4-9) allowed six hits, walked one and struck out six, hurling 70-of-99 pitches for strikes.
Brad Ziegler tossed a 1-2-3 ninth for his ninth save as the D-backs took a second win in three game against the Giants.
Paul Goldschmidt's RBI triple in the fifth inning broke a 1-1 tie and Gerardo Parra also drove in a run for Arizona.
Giants starter Matt Cain (8-9) was hung with the loss, yielding two runs on eight hits in a 6 1/3-inning stint.
Marco Scutaro drove in San Francisco's only run.