[BUG] Agent SDK sessions with setting_sources=[] still connect the user's claude.ai connectors (Gmail, Calendar, X, …) unless strict MCP config is set
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
A programmatic Agent SDK session started with setting_sources=[] (meant to load no user, project or local settings) and a one-line prompt ("Reply with just: ok") still attempted to connect all of the user's claude.ai connectors through mcp-proxy.anthropic.com. Its MCP logs in ~/Library/Caches/claude-cli-nodejs/<cwd-slug>/mcp-logs-claude-ai-* show connection attempts to 7 connectors (Gmail, Calendar, X, Exa, Context7, Claude Docs, Claude Code Documents). 5 were established, no tool calls were made, and all closed within about 1 s. Afterwards ~/.claude.json contained claudeAiMcpEverConnected listing those connectors.
Only sessions that also set strict MCP config (no MCP servers) avoided this. For a session explicitly configured not to load the user's settings, connecting their email and calendar connectors is surprising, and it isn't documented on the SDK pages as far as I can tell.
What Should Happen?
setting_sources=[], or a clearly documented option, should keep claude.ai connectors out of programmatic sessions by default. Or the SDK docs should state plainly that claude.ai connectors load regardless of setting_sources unless strict MCP config is used.
Steps to Reproduce
- Have claude.ai connectors enabled on the account (e.g. Gmail, Calendar).
- Run an Agent SDK
query()withClaudeAgentOptions(setting_sources=[], cwd=<empty temp dir>)and prompt "Reply with just: ok". - Inspect
~/Library/Caches/claude-cli-nodejs/<temp-cwd-slug>/and seemcp-logs-claude-ai-*folders with connection logs. - Check
~/.claude.jsonforclaudeAiMcpEverConnected.
Is this a regression?
I don't know
Claude Code Version
2.1.304 (claude-agent-sdk 0.2.168)
Platform
Anthropic API
Operating System
macOS (26.x)
Terminal/Shell
Other (Ghostty)
Additional Information
Related: #99513 (stale claudeAiMcpEverConnected injects connector tools), #81083 (connector registration timing), #103797 (filed today: no isolated-config mode for SDK sessions).