[BUG] context: fork skills and spawned team agents inherit wrong project cwd and MCP config
Summary
When a context: fork skill spawns a team via Teammate(operation: "spawnTeam") and Task(team_name: ...), the forked lead agent and all spawned teammates resolve to the wrong project directory. This causes them to load the wrong project's .mcp.json, silently connecting to entirely different services.
Steps to Reproduce
- Have two projects (Project A and Project B), each with their own
.mcp.jsoncontaining the same MCP server name (e.g.,linear-server) but different auth tokens pointing to different workspaces - Open Claude Code in Project A
- Run a
context: forkskill that spawns a team with multiple agents - Inspect the team config at
~/.claude/teams/<team-name>/config.json
Expected Behavior
All agents should have cwd set to Project A's directory and load Project A's .mcp.json, connecting to Project A's services.
Actual Behavior
All agents have cwd set to Project B's directory — a completely different project. They load Project B's .mcp.json and silently connect to the wrong services.
// ~/.claude/teams/<team-name>/config.json
{
"members": [
{
"name": "team-lead",
"cwd": "/path/to/project-b/"
},
{
"name": "agent-1",
"cwd": "/path/to/project-b/"
}
]
}
Project B happened to be the most recently modified project in ~/.claude/projects/, suggesting the fork may be resolving to the last-active project rather than the invoking project.
Impact
This is a silent data isolation failure. Because both projects had an MCP server named linear-server (with different auth tokens for different workspaces), the agents:
- Connected to the wrong issue tracker workspace and retrieved tickets from the wrong project
- Would have connected to the wrong Render account (wrong production infrastructure)
- Would have connected to the wrong PostHog project (wrong analytics data)
- Ran
git logsearches against the wrong codebase
There was no error or warning. The only way I noticed was that the returned ticket IDs had the wrong prefix.
Why This Is Dangerous
If the two projects' MCP servers didn't share a name, the agents would fail loudly ("tool not found"). But because the server names collide (a natural pattern when multiple projects use the same services), the wrong config is silently loaded and used successfully — returning plausible but completely wrong data.
Environment
- Claude Code: 2.1.32
- OS: macOS (Darwin 25.2.0, arm64)
- Skill frontmatter:
context: fork - Global MCP config: None (
~/.claude/mcp.jsondoes not exist, nomcpServersinsettings.json) - Project MCP config: Both projects use
.mcp.jsonwith project-scoped auth tokens
Attempted Workarounds
- No
cwdparameter exists on the Task tool, Teammate tool, or skill frontmatter - Renaming the MCP server (e.g.,
linear-server→linear-project-a) would make it fail loudly instead of silently, but wouldn't fix the functionality - Hardcoding paths in prompts can fix
git/bashcommands, but cannot fix which.mcp.jsongets loaded
Related Issues
- #13898 — Custom subagents cannot access project-scoped MCP servers
- #17283 — Skill tool should honor
context: forkfrontmatter - #17668 — MCP Context Isolation feature request
- #10061 — Sub-agents load skills from global directory instead of project directory
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗