Task tool fails with 'Tool names must be unique' error when MCP servers are enabled

Resolved 💬 6 comments Opened Oct 31, 2025 by Jayyo Closed Jan 10, 2026

Bug Description

The Task tool (used for spawning sub-agents) fails with error tools: Tool names must be unique when MCP servers are enabled, specifically Playwright MCP in my case.

Steps to Reproduce

  1. Enable any MCP server (e.g., Playwright):

``bash
claude mcp add playwright
``

  1. Try to use the Task tool with a sub-agent:

``
Task tool with subagent_type=Explore
``

  1. Observe the error

Expected Behavior

Task tool should work correctly even when MCP servers are enabled, with sub-agents having access to all available tools including MCP tools.

Actual Behavior

API Error: 400

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "tools: Tool names must be unique."
  }
}

Root Cause Analysis

When Task tool spawns a sub-agent:

  1. The sub-agent tries to load all available tools
  2. MCP server tools are already loaded in the parent session
  3. Tool names collide when the sub-agent tries to re-register them
  4. This causes the "Tool names must be unique" error

Workaround

Temporarily disable MCP servers:

claude mcp disable playwright

Environment

  • Claude Code Version: 2.0.30 (native build)
  • OS: Ubuntu 24.04.3 LTS (Linux 6.14.0-33-generic)
  • MCP Server: Playwright MCP (@playwright/mcp)
  • Active MCP Servers: 1 (playwright)

Additional Context

  • Other tools (Glob, Grep, Read, Bash) work fine with MCP enabled
  • Only Task tool is affected
  • This blocks parallel multi-agent workflows when MCP is active

Suggested Fix

Sub-agents should either:

  1. Inherit the parent's tool registry without re-registering
  2. Skip duplicate tool registration with a warning
  3. Namespace MCP tools differently for parent/child contexts

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗