This applies to headless mode, where Claude Code is run by another program through the SDK (a developer toolkit) instead of in a terminal window. That program can send set_cwd to change the folder Claude Code works in. When set_cwd actually changes the folder, Claude Code now:
- Removes stale connections to MCP servers (outside programs that give Claude extra tools) and clears their cached data.
- Removes project MCP configurations that no longer match the new folder.
- Refreshes plugin state.
- Restarts local MCP servers that were started in the original launch folder, when the response marks a fresh session, and waits for them to reconnect.
The restarted servers are ones that talk to Claude Code over stdio, meaning through a directly started local process. They come back up with the new project folder as their base.
Previously an MCP server started in the launch folder could keep working against that folder after the directory change. Now the servers of a fresh session follow the new project, so their tools see the right files.