claude-code - 💡(How to fix) Fix [BUG] workingDirectory not updated on "! cd <dir>" [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55688Fetched 2026-05-03 04:47:05
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

The MCP client (Claude Code) sends a stale workingDirectory in _meta when calling MCP tools. If you start a session in repo A then cd to repo B, the MCP tools still think you're in repo A. This causes auto-detection of repo and head to return values from repo A.

What Should Happen?

Claude should pass the working directory of the current repo to the MCP

Error Messages/Logs

Steps to Reproduce

  1. start claude in a repo
  2. ! cd<repoB>
  3. call an MCP method and print the workingDir inside of it

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.126 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

Update the workingDirectory in the _meta object to reflect the current repository before calling MCP tools.

Guidance

  • Verify that the workingDirectory is being updated correctly when the user changes repositories by adding logging or debugging statements.
  • Check the implementation of the cd command in Claude Code to ensure it updates the workingDirectory variable.
  • Review the MCP tool integration to ensure it uses the updated workingDirectory value.
  • Test the fix by following the steps to reproduce and verifying that the correct repository is detected.

Example

No code snippet is provided as the issue does not contain sufficient information about the implementation.

Notes

The fix may require changes to the Claude Code implementation, specifically the cd command and the MCP tool integration. Without more information about the code, it is difficult to provide a more detailed solution.

Recommendation

Apply workaround: Update the workingDirectory in the _meta object to reflect the current repository before calling MCP tools, as this is the most likely cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] workingDirectory not updated on "! cd <dir>" [1 comments, 2 participants]