[BUG] Duplicate tools when using an "sdk" McpServer

Status Fixed / completed
Maintainer reply ✓ Yes — dltn
Activity 6 comments · opened Sep 15, 2025 · closed Sep 19, 2025
💡 Likely answer: A maintainer (dltn, contributor) responded on this thread — see the highlighted reply below.

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?

When passing an MCP server of type "sdk" into the TS SDK, on the second message of a multiturn chat, I am getting the problem:

API Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"tools: Tool names must be unique.\"},\"request_id\":\"req_011CTA5VA5xFXK2mkaw27P2y\"}

I added the oninitialize callback on my custom MCP server, and noticed that it is being initialized twice.

Not sure if this is a problem on how I've setup the server, or if there is a bug on the Claude Code side, but I am only creating the SDK server once and passing it into mcpServers once and I am getting this behavior.

The diff of our implementation is here, where we moved it from an HTTP server to an SDK one: https://github.com/zed-industries/claude-code-acp/pull/50/files#diff-8a5c4a5a3d949e31532fec3de206c63c156b3155181a27534871599db24c3899R149

What Should Happen?

I would expect when passing in an SDK MCP server it would only get initialized once, and the tools wouldn't get sent to the model more than once.

Error Messages/Logs

Steps to Reproduce

  • Pass in an MCP server of type "sdk" in the config
  • Send two subsequent messages to the SDK

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

1.0.113

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

6 Comments

dltn contributor · 1 year ago

Great catch, @benbrandt! Will be fixed in the next release.

benbrandt · 1 year ago

@dltn I've seen a few new releases, but am still seeing the same behavior. I assume you'll update the ticket once this is fixed?

n4cr · 1 year ago

I'm having this issue constantly as well. I'm running it in a container trying to use the sdk tools.

dltn contributor · 1 year ago

@benbrandt hmm, should've been out in v1.0.118. You're still seeing issues on/after that version?

benbrandt · 1 year ago

@dltn thanks it is working now! I saw 1.0.118, but it was only tagged as a next release so I wasn't sure if it was ready or not.
but both it and v1.0.119 are working. Thanks!

github-actions[bot] · 1 year ago

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.