[BUG] SDK doesn't read from .mcp.json until the CLI is ran in the current working directory
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?
I have a .mcp.json file in my current working directory. Upon launching the Claude Agent SDK from that directory, Claude doesn't seem to have access to any of the MCP servers defined in my .mcp.json file.
This can be verified by calling both the mcpServerStatus() callback and examining the mcp_servers field in SDKSystemMessages received while running query. Both will not have any of the servers configured in my .mcp.json file.
Both of the above methods _will_ start to return valid data after I:
- Launch
claudefrom the CLI in my current working directory - Restart the SDK
NOTE: This problem does not occur for local or user scoped MCPs. Those work just fine in the Claude Agent SDK. Only project scoped MCPs have this problem.
What Should Happen?
The Claude Agent SDK (just as the CLI) should read from the .mcp.json file in my current working directory upon startup _without_ relying on the CLI starting up in that directory.
Error Messages/Logs
Steps to Reproduce
- Create a
.mcp.jsonfile in your current working directory. - Run the
query()function with anAsyncIterableprompt in the Claude Agent SDK. - Either call the
mcpServerStatus()callback, or send a message and examine themcp_serversfield on all messages received of typeSDKSystemMessage. - Launch the Claude Code CLI from the current working directory, then run
/mcp(you'll see the server(s) defined in your.mcp.jsonappear here) - Close the existing
AsyncIterable, and launch a newquery()function using the Claude Agent SDK. - Either call
mcpServerStatus()or send a message and examine themcp_serversfield on a message of typeSDKSystemMessage. It will be populated correctly now with the value from your.mcp.jsonfile.
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.54
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Non-interactive/CI environment
Additional Information
_No response_
7 Comments
Are you saying it doesn't load the first time but it loads the second time? It shouldn't load at all unless you've specified
projectas asettingSourcesoption: https://platform.claude.com/docs/en/agent-sdk/typescript@ashwin-ant Yes, but it _only_ loads the second time if I launch
claudefrom the CLI and run/mcp(and then restart my SDK process).And apologies, I forgot to clarify, but we do have
projectset insettingSources. We are passing in:Just wanted to say I really hope this bug gets fixed soon. We use conductor to run claude and its an amazing product. Only issue is that our .mcp.json doesn't get read properly so i have to open claude separately to do any workflows that require mcps.
Solving this issue would be a big game changer for my team's work processes!
Any updates on this? This is greatly hindering our team's workflow with conductor as well.
hmmm just hit this too trying out conductor, can't use it like this
Hey, this should be fixed in the latest release coming out today - please upgrade and let me know if you continue to have issues
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.