[BUG] MCP tools fail with "tool_use ids must be unique" when run via launchd
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment:
- Claude Code version: 2.1.19
- macOS
- Running via launchd scheduled task
What happens:
When Claude Code is run via launchd with MCP servers loaded (using --mcp-config), any attempt to use MCP tools fails
with:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: tool_use ids
must be unique"}}
What works:
- Running the same command interactively in Terminal
- Running via launchd WITHOUT using MCP tools
- Loading MCP config via launchd (tools appear) but not calling them
What Should Happen?
Expected: MCP tools should work the same via launchd as they do interactively.
Error Messages/Logs
Steps to Reproduce
Reproduction:
- Create a launchd plist that runs claude with --mcp-config pointing to valid MCP servers
- Use -p with a prompt that asks Claude to use an MCP tool
- Observe the tool_use ID collision error
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.19
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗