[BUG] SDK doesn't read project level MCPs or Slash Commands for new queries

Status Open
Reported on v2.0.76
Maintainer reply None cached
Activity 10 comments · opened Jan 4, 2026

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 project level MCPs defined in my .mcp.json file and a few slash commands added under my projects .claude/commands directory. Upon launching the Claude Agent SDK from that directory, Claude doesn't seem to have access to either the MCP servers or slash commands defined in these project-level files.

This can be verified by calling the supportedCommands() and mcpServerStatus() callbacks after launching the SDK. They don't return project-level MCPs/commands.

Note: These methods DO however return user-level MCPs and Slash Commands under the same situation.

What Should Happen?

The Claude Agent SDK (just as the CLI) should read from the .mcp.json file and .claude/commands directory in my current working directory upon startup.

Error Messages/Logs

Steps to Reproduce

  1. Create a .mcp.json file in your current working directory.
  2. Create a command under .claude/commands in your current working directory.
  3. Run the query() function with an AsyncIterable prompt in the Claude Agent SDK.
  4. Call the mcpServerStatus() and supportedCommands callbacks
  5. Verify that the results do not contain project level MCPs and slash commands

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Non-interactive/CI environment

Additional Information

A similar issue was opened earlier this month but the issue does not seem to have been resolved.
Previous Issue: https://github.com/anthropics/claude-code/issues/13107

View original on GitHub ↗

10 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/13107
  2. https://github.com/anthropics/claude-code/issues/8430
  3. https://github.com/anthropics/claude-code/issues/15215

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

toml0007 · 7 months ago

👍

mikecfisher · 7 months ago

I can confirm I have the same issue. Hoping to see a fix soon.

scald · 7 months ago

+1

irfndi · 7 months ago

👍

LoicReco · 7 months ago

+1

abix5 · 7 months ago

+1

soldier99 · 7 months ago

+1

github-actions[bot] · 6 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

yurukusa · 5 months ago

This is a known gap — the Agent SDK doesn't automatically discover project-level configurations the way the CLI does.
Workaround 1 — Pass project-level MCP config explicitly:
When initializing the SDK, you can specify MCP servers directly:

import { Claude } from '@anthropic-ai/claude-code';
const claude = new Claude({
  cwd: '/path/to/your/project',
  // The SDK should respect cwd for project discovery
});

Make sure to set cwd to your project root. Some SDK versions use this to locate .mcp.json and .claude/.
Workaround 2 — Copy project configs to user level:
As a temporary measure, you can symlink or merge project-level configs into user-level:

ln -s /path/to/project/.mcp.json ~/.claude/.mcp.json
ln -s /path/to/project/.claude/commands/* ~/.claude/commands/

This is a blunt approach — all projects will see these configs. Use with caution if you have multiple projects.
Workaround 3 — Use the CLI in headless mode instead of the SDK:
If the SDK's project discovery is a blocker, claude -p (headless/pipe mode) respects project-level configs:

echo 'Your prompt here' | claude -p --cwd /path/to/project

This gives you programmatic access with full project-level MCP and command support, at the cost of managing stdio instead of using the SDK's API.