[BUG] SDK doesn't read from .mcp.json until the CLI is ran in the current working directory

Resolved 💬 7 comments Opened Dec 5, 2025 by omidmogasemi Closed Dec 16, 2025

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:

  1. Launch claude from the CLI in my current working directory
  2. 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

  1. Create a .mcp.json file in your current working directory.
  2. Run the query() function with an AsyncIterable prompt in the Claude Agent SDK.
  3. Either call the mcpServerStatus() callback, or send a message and examine the mcp_servers field on all messages received of type SDKSystemMessage.
  4. Launch the Claude Code CLI from the current working directory, then run /mcp (you'll see the server(s) defined in your .mcp.json appear here)
  5. Close the existing AsyncIterable, and launch a new query() function using the Claude Agent SDK.
  6. Either call mcpServerStatus() or send a message and examine the mcp_servers field on a message of type SDKSystemMessage. It will be populated correctly now with the value from your .mcp.json file.

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_

View original on GitHub ↗

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