Task agent fails with 'tools: Tool names must be unique' when parent has many MCP tools
Bug: Task agent fails with "tools: Tool names must be unique" when parent has many MCP tools
Environment
Claude Code Information:
- Version: 2.0.30
- Install method: Global
- Node.js version: v24.10.0
System Information:
- OS: macOS (Darwin Kernel 25.0.0)
- Architecture: ARM64 (Apple Silicon)
- Terminal: iTerm2
- Shell: bash
MCP Configuration:
- Total MCP servers: 13 servers
- Total unique tools: 74 tools
- Configuration scope: Mixed (12 project-level + 1 global)
MCP Server Inventory
Project-level servers (configured in /Users/sc/Documents/GitHub/.claude.json):
arxiv-mcp-server- 4 tools (stdio, uv)claude-skills- 3 tools (stdio, uvx)clear-thought-mcp-server- 11 tools (stdio, npx/smithery)context7- 2 tools (stdio, npx)lightpanda- 5 tools (stdio, local binary)mcp-deepwiki- 1 tool (stdio, npx)mnemex- 13 tools (stdio, local binary)playwright- 21 tools (stdio, npx)perplexity-search- 1 tool (stdio, npx/smithery)mcp-mermaid- 1 tool (stdio, npx)obsidian-mcp-server- 8 tools (stdio, npx)ai-humanizer- 1 tool (stdio, npx)
Global server (configured in root .claude.json):
deepwiki- 3 tools (HTTP transport)
Description
Task agent subprocess launches fail with API error when the parent Claude Code process has many MCP servers configured. Commands that rely on the Task tool (like /sidequest) consistently fail to launch background agents.
Critical: This occurs despite:
- All 74 tools being properly namespaced (
mcp__<server>__<tool>) - No duplicate tool names in the main process
- Valid MCP server configuration
- Main Claude Code session working perfectly with all tools
Error Message
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools: Tool names must be unique."}}
Steps to Reproduce
- Configure 12+ MCP servers in project
.claude.jsonwith mixed transports (stdio, HTTP) - Configure 1+ global MCP server in root
.claude.json - Verify main process works: run any command that uses MCP tools directly
- Attempt to launch Task agent subprocess: run
/sidequest <any query> - Observe immediate failure with "tools must be unique" error
Expected Behavior
Task agent subprocess should:
- Successfully launch with inherited tool configuration
- Receive properly namespaced tools from parent process
- Execute the requested task independently
Actual Behavior
Task agent subprocess:
- Fails immediately during initialization
- Returns 400 error about duplicate tool names
- Never begins actual task execution
- Forces fallback to direct execution in main process
Detailed Technical Analysis
Configuration Validation
I verified the configuration extensively:
# All 74 tools have unique names
$ python3 << 'PYTHON'
from collections import Counter
tools = [<all 74 tool names>]
counts = Counter(tools)
duplicates = {t: c for t, c in counts.items() if c > 1}
print(f"Duplicates: {duplicates}") # Output: {}
print(f"Total: {len(tools)}, Unique: {len(set(tools))}") # 74, 74
PYTHON
Result: Zero duplicate tool names in main process configuration.
Tool Namespacing
All tools follow proper MCP namespacing convention:
mcp__<server-name>__<tool-name>
Example:
mcp__arxiv-mcp-server__search_papersmcp__mnemex__save_memorymcp__playwright__browser_navigate
Even the potentially confusing servers are properly namespaced:
deepwiki(global) →mcp__deepwiki__read_wiki_contentsmcp-deepwiki(project) →mcp__mcp-deepwiki__deepwiki_fetch
Hypothesis: Subprocess Tool Inheritance Bug
The error occurs specifically during Task agent subprocess initialization:
- Parent process (main Claude Code session):
- Loads 13 MCP servers successfully
- Registers 74 unique tools
- Functions normally with all tools
- Subprocess creation (Task agent launch):
- Attempts to inherit tool configuration from parent
- Something in serialization/deserialization creates duplicates
- Anthropic API rejects request before agent starts
Possible causes:
- Tools added twice during subprocess initialization
- MCP server lifecycle issues when spawning subprocess
- Tool configuration serialized incorrectly for API request
- Parent process tool list merged incorrectly with subprocess defaults
Relation to v2.0.30 Changelog
The v2.0.30 changelog states:
"Fixed MCP tools not being available to sub-agents"
This suggests the Claude Code team attempted to fix tool availability in subprocesses. However, the fix may have introduced a regression where tools are now duplicated instead of being unavailable.
Timeline:
- Pre-2.0.30: MCP tools unavailable to sub-agents (original bug)
- v2.0.30: Attempted fix for tool availability
- Post-2.0.30: Tools available but duplicated (new regression)
Impact
Affected functionality:
/sidequestcommand completely non-functional- Any custom agent that uses Task tool fails
- Background research agents cannot be launched
- Multi-agent workflows broken
Workarounds discovered:
- Temporarily disable MCP servers via
/mcpbefore Task agent launch - Create minimal workspace with subset of MCP servers
- Execute tasks directly in main process (defeats purpose of agents)
Related Issues
- Issue #703 (closed): Similar error message but different cause (slash command collision with MCP). Fixed in v0.2.64.
- No other reports found for this specific Task agent + MCP tool duplication bug
Reproduction Rate
100% reproducible with configuration of 74 MCP tools across 13 servers.
Unknown threshold - needs testing:
- Does it occur with fewer tools? (e.g., 50 tools, 10 servers)
- Is there a tool count limit for subprocesses?
- Does it depend on transport type mix (stdio vs HTTP)?
Logs/Additional Context
Attempted Task launch (excerpt):
# First attempt
Task tool call → API Error 400 "tools must be unique"
# Immediate retry
Task tool call → API Error 400 "tools must be unique"
# Both attempts failed before agent could start
Main process continues to function normally with all tools after failed subprocess launch.
Request
Could the Claude Code team:
- Investigate subprocess tool inheritance mechanism in v2.0.30
- Add debug logging for tool registration during subprocess creation
- Consider tool count limits or configuration validation
- Test with large MCP configurations (10+ servers, 50+ tools)
This appears to be a regression introduced by the MCP sub-agent availability fix in v2.0.30.
30 Comments
I am seeing this behavior with a single MCP server.
Seeing the same error but I have zero MCP servers.
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
It appears to be with the general Task agents: Explore/Plan/general-purpose (these all return "Done (0 tool uses · 0 tokens · 1s)") when any MCP server is enabled, whether project or user based.
Yet other custom agents (stored in
.claude/agents/) seem to function as per normal with MCP servers enabled.Deleted all MCP configurations and the 3 function as per normal.
Additional API Error Details (via Claude Code assistant testing):
When attempting to invoke any built-in subagent with MCP servers enabled, the following API error is consistently returned:
This error occurs for:
subagent_type: "Explore"subagent_type: "Plan"subagent_type: "general-purpose"But NOT for custom agents defined in
.claude/agents/*.md:Root cause hypothesis: When MCP servers are enabled, the tool registration system appears to be duplicating tool names when constructing the built-in subagent tool configurations, causing the API to reject the request due to non-unique tool names in the tools array.
Environment: Claude Code v2.0.30+ with any MCP server configuration enabled (Context7 MCP server confirmed in testing).
Update: Inconsistent results with custom agents across multiple projects. Some execute correctly whilst others fail with similar issues.
Can confirm, same issue on 2.0.30 - reverting to 2.0.29 makes my agents works again. Worth noting my project agents were also affected.
Me too. Feedback ID: 815421a5-d203-4745-9fad-a0d621fa0cc2
this issue for me on 2.0.30. however, i'm just trying to basic agent call with agents that have worked forever. the agents are defined in .claude/agents/* . none of them are doing subagents, this is just strait, normal agent call from the claude code terminal, and all of them fail. this is pretty problematic.
I've been reverting to 2.0.28 to continue working:
2.0.30 should probably be retracted given how bad this bug is.
Rewinding doesn't work. BUT relaunching and resuming has worked a few times for me now. That indicates that reverting may not work much better than just relaunching. (though reverting will ensure it won't come back?)
i have tried relaunching, it didn't fix the issue for me. only reverting to an older version fixed it. i've even started brand new claude code chats and agent was still broken on .30.
Some poor anthropic SRE must be having a
CLAUDE_CODE_FORCE_HALLOWEENof their own tonight!I kid I kid. That is the name of a new env var tonight though.
If you don't need to use an MCP for a subagent, try turning off the MCP with the new
@, THEN restarting.It's a teeny tiny bit of a pain for planning (where I use subagents for the most part!) but it works okay right now if I tell claude some variant of "the xcodebuildmcp is currently disabled, but I will enable it before we begin work, ensure that in the first step of the plan you propose, you will pause and wait for me to enable it before proceeding".
Curious discovery: even with @cameroncooke's XCodeBuildMCP disabled via the claude code UI, claude code is guessing the names of tools, e.g.:
It may be very good at guessing things in general, but getting it that close indicates to me that maybe there are bits of it left in the context window, and it's echoing through the weird transformer brain far enough to reach the output. That would then explain the duplicate tool error, some code somewhere leaving it in the window and then dumping it in a second time later.
meet exact the same problem in 2.0.30. using same prompts in 2.0.29 is ok.
Temporarily using version 2.0.29
Quick tip if anyone is looking to downgrade until a fix is available. You could use npx to work with 2.0.29 temporarily
npx @anthropic-ai/claude-code@2.0.29Getting this and many other issues in 2.0.30
This fixed the issue for me as well
Temp fix in .zshrc
alias claude="npx @anthropic-ai/claude-code@2.0.29" # temp fix until 2.0.30 is fixedConfirmed with no MCP tools but with subagents as well.
Also confirmed using 2.0.29 fixed the issue from @Lukavyi 's comment above
Investigation Report: Task Tool API Error
Root Cause Identified
Source: Claude Code CLI tool deduplication bug
Location: Claude Code CLI internals (not MCP, not macOS, not plugin issue)
What's Happening
When the Task tool tries to spawn a subagent:
Evidence
✅ Confirmed it's NOT:
✅ Confirmed it IS:
Technical Details
Error Response:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "tools: Tool names must be unique."
},
"request_id": "req_011CUfS5JpvanCFYUvqNJXdJ"
}
Tool Sources in Session:
Why Direct Tools Work
When I call tools directly (Read, Edit, Write, Bash), Claude Code CLI doesn't need to:
The bug only triggers when Task tool tries to create a subagent environment.
Workaround (Current)
✅ Use direct tool calls instead of Task tool subagents
✅ All other functionality works perfectly
✅ Implementation completed successfully despite this limitation
Fix Required
Claude Code CLI needs to implement proper tool deduplication when spawning Task tool subagents. This is a client-side bug that should be reported to
the Claude Code team.
Recommendation: File a GitHub issue at https://github.com/anthropics/claude-code/issues with this investigation report.
Fix landing in 2.0.31 later today
Is there a way to use this already with some "next" flag or something?
You're going to get generally suboptimal bug report generation from an LLM like claude ("Only affects Task tool (subagent spawning)" is plain wrong) because claude doesn't have access to the original uncompiled and unpackaged claude code cli source code.
This affected Plan and Explore subagents too.
If you need to workaround this my workflow has been
@ashwin-ant
Some suggestion to prevent such issues in the future:
1) Suggestion: Add separate braveheart releases with auto updates into versions that are not yet deemed stable. While updating the rest of us only into versions that have had some time to stabilize.
2) Monitor logging during integration tests, if there are any error logs fail the integration tests. So when you test core functionality and get failed to spawn an agent issue the tests break.
Start claude using
npx @anthropic-ai/claude-code@2.0.29instead ofclaudefor now2.0.31 is out!
I am still seeing this as an issue, when using claude-agent-sdk 0.1.30 which has parity to 2.0.31.
https://github.com/ceedaragents/cyrus/blob/1c53bf7440a624a459e1a7b3756a8b74f4a27a62/pnpm-lock.yaml#L109
Update, per the changelog 0.1.30 of claude-agent-sdk was supposed to include 2.0.31, but in practice seems to still have 2.0.30. Here's some evidence of that:
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.