Agent-scoped inline mcpServers (stdio) never forwards trailing directory argument...
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?
A subagent defined with agent-scoped inline mcpServers in its frontmatter,
pointing to a local stdio MCP server (filesystem-style, e.g.
@modelcontextprotocol/server-filesystem or an Obsidian vault server) that
expects a trailing directory argument, never receives that argument. The
spawned server process falls back to process.cwd() instead of the
configured vault/directory path.
What Should Happen?
list_allowed_directories should return the configured vault/target directory
(the trailing argument in the server's args), not the Claude Code session's
own working directory (process.cwd()).
Error Messages/Logs
Allowed directories:
C:\Users\HUAWEİ\OneDrive\Masaüstü\ATLAS_CODEX_COMPLETE_LATEST_STATE_2026-07-30\SOURCE_REPOSITORY\SOURCE_REPOSITORY
Steps to Reproduce
- Define a subagent (.claude/agents/<name>.md) with frontmatter:
---
mcpServers:
<server-name>:
command: <path>
args: ["<path-to-server-script>", "<target-directory>"]
---
- Invoke the subagent and call its
list_allowed_directories(or
equivalent) tool.
- Expected: returns <target-directory>.
- Actual: returns the Claude Code session's own working directory
(process.cwd() of the parent process), not the configured directory
argument.
Note: also confirmed reproducing via project-level .mcp.json with a
by-name reference from agent frontmatter (not just inline config) — the
bug is not scoped to inline definitions specifically.
The same server, launched manually outside Claude Code with the identical
command/args, correctly resolves the target directory — isolating the bug
to how Claude Code spawns/forwards args for agent-scoped mcpServers.
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.224
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Makes agent-scoped mcpServers unusable for any stdio server whose
behavior depends on a directory/path argument (filesystem servers, vault
servers, etc.) — the server silently operates against the wrong
directory instead of failing loudly, which is worse than a hard error.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗