settingSources: [] still loads user-level MCP servers and skills
Bug Description
When using the Claude Agent SDK with settingSources: [] (documented as "SDK isolation mode"), user-level MCP servers and skills are still loaded into agent sessions. This causes significant token overhead (~30K extra tokens per session) from tool definitions that the agent doesn't need.
Reproduction
import { query } from '@anthropic-ai/claude-agent-sdk';
for await (const msg of query({
prompt: 'Say ok',
options: {
systemPrompt: 'Respond with just "ok".',
model: 'claude-haiku-4-5',
tools: [],
settingSources: [], // should mean full isolation
maxTurns: 1,
permissionMode: 'default',
},
})) {
// Check usage on assistant message — cache_creation_input_tokens is ~35K
// even though no tools or settings should be loaded
}
Expected Behavior
With settingSources: [], the SDK docs state: "When omitted or empty, no filesystem settings are loaded (SDK isolation mode)." This should mean:
- No user-level MCP servers loaded (from
~/.claude/settings.json) - No user-level skills loaded (from
~/.claude/skills/) - No managed skills loaded (from
/Library/Application Support/ClaudeCode/.claude/skills)
Actual Behavior
SDK debug logs show:
Loading skills from: managed=/Library/Application Support/ClaudeCode/.claude/skills, user=/Users/xxx/.claude/skills, project=[...]
And user-level MCP servers (Gmail, PostHog, Granola, Playwright, Linear — whatever the user has configured) are loaded, adding their tool definitions to the context.
Token impact: ~35K cache_creation tokens with settingSources: [] + tools: [], vs an expected baseline of ~5-10K for just the system prompt.
Workarounds Found
strictMcpConfig: true— blocks user MCP servers (reduces ~57K → ~26K tokens)extraArgs: { 'disable-slash-commands': null }— should block user/managed skills (untested reduction)
Environment
- SDK version: 0.2.63
- Node: 24.13.0
- OS: macOS (Darwin 24.6.0, arm64)
Related Issues
- #176 —
settingSourcesignored in V2 Session API (similar symptom) - #124 — Feature request for Tool Search to reduce token usage
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗