The 29-year-old McClain was just one season removed from signing a four-year, $21 million deal with the Redskins.
McClain, who is listed at 6-foot-2 and 300 pounds, recorded just 17 tackles and two sacks in 12 games last season. He missed Weeks 12-15 with a toe injury.
McClain was originally selected by the Carolina Panthers in the third round of the 2011 NFL Draft. He also played for the New England Patriots, Houston Texans and Dallas Cowboys before playing one season with the Redskins.
During his time with Houston in 2013, McClain was under the tutelage of assistant defensive line coach Jeff Zgonina. Zgonina is now the defensive line coach for the 49ers.
San Francisco's defensive tackle depth features Earl Mitchell, DeForest Buckner, D.J. Jones and Sheldon Day. The 49ers also selected Jullian Taylor in the seventh round of the 2018 NFL Draft, with Taylor already under contract after recording 52 tackles and one sack in 20 games at Temple.