The 21-year-old defenseman, who was a restricted free agent, had 28 points (seven goals, 21 assists) in 54 regular-season games with the Bruins last season and eight points (two goals, six assists) in 23 Stanley Cup Playoff games.
McAvoy said he was glad to have his contract settled in time to get ready for the season. Boston had its first practice of training camp Friday and opens the regular season Oct. 3 at the Dallas Stars.
"I just wanted to be a part and be back with everybody," he said. "We have something really special with this group, and I know that's been said since the moment I got here. ... I just missed everybody a lot, so I'm excited to be back, and like I said I get to focus now on integrating back with whatever group I'm with for camp and just focusing on being the best player I can be."
McAvoy led the Bruins in average ice time last season (22:10) and in the playoffs (24:30), when they advanced to the Stanley Cup Final before losing to the St. Louis Blues in seven games.
General manager Don Sweeney said McAvoy is a key to Boston's success, and that the three-year term is good for each side.
"I looked at this nothing other than well beyond three years as to what Charlie's going to play for the Boston Bruins," Sweeney said. "But we're obviously excited that we got him back in the group here, an important, important part of our hockey club, this year, last year and many years going forward."
"I just think to find a common ground that everybody seeks to finalize a deal, it puts Charlie in a situation where he can take this platform and really launch himself into the player we all believe he is and will become, both on and off the ice, incorporating leadership qualities he exhibits as well. So for us I think it's just a good compromise, a middle ground, that allows him to take it wherever he's capable of taking it. And the Bruins will be there when he does."
Selected by Boston in the first round (No. 14) of the 2016 NHL Draft, McAvoy has 60 points (14 goals, 46 assists) in 117 regular-season games and 16 points (three goals, 13 assists) in 41 playoff games.
"My goal is to go out and become the best hockey player I can be, to grow into one of the best defensemen hopefully in the League," McAvoy said. "I feel like the sky is the limit. I'm going to continue to push myself every single day to grow and be better and do everything I can for this team, and I feel like this is an opportunity, a bit of a window here, for me to go and do just that."
There are several high-profile restricted free agents who remain unsigned, including forwards Mikko Rantanen of the Colorado Avalanche,
Brayden Point
of the Tampa Bay Lightning, Matthew Tkachuk of the Calgary Flames, Brock Boeser of the Vancouver Canucks and Patrik Laine and Kyle Connor of the Winnipeg Jets. Bruins restricted free agent defenseman
Brandon Carlo
also is unsigned.
NHL.com independent correspondent Matt Kalman contributed to this report