Skip to content

Conversation

meanderix
Copy link
Contributor

@meanderix meanderix commented Sep 1, 2025

Description

It was made possible specifiying a current working directory (cwd) for mcp servers in the following PR.

However, unless cwd is manually set in the MCP server definition itself, there is no way for the MCP server to resolve cwd to the current workspace directory. This causes issues with some of the original Anthropic MCP servers, such as mcp-server-git. See #7173.

The following PR attempts to adjust the logic so that unless cwd is manually set, we use the workspace folder. (As far as I can tell, unless we do this, the cwd is actually resolved to path of the vscode binary.)

This makes mcp-server-git (and other mcp servers) work in multiple projects without having to manually update cwd.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-general-review or @continue-detailed-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Tests


Summary by cubic

Default MCP server cwd to the current workspace root when not explicitly set. This fixes path resolution issues and lets servers like mcp-server-git work across projects without manual config.

  • Bug Fixes
    • Resolve cwd from IDE workspace dirs when not provided.
    • Preserve user-provided cwd as-is.
    • Avoids defaulting to the VS Code binary path.

@meanderix meanderix requested a review from a team as a code owner September 1, 2025 07:20
@meanderix meanderix requested review from tomasz-stefaniak and removed request for a team September 1, 2025 07:20
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 1, 2025
Copy link

github-actions bot commented Sep 1, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@meanderix
Copy link
Contributor Author

An open question would be how to handle manually specified relative paths. Do we want them to be relative to the vscode folder or to the workspace folder?

@meanderix meanderix changed the title Enhancement: Adjusted MCPConnection logic so the cwd is resolved to current workspace folder. feat: Adjusted MCPConnection logic so the cwd is resolved to current workspace folder. Sep 1, 2025
@meanderix
Copy link
Contributor Author

recheck

@meanderix
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@RomneyDa
Copy link
Collaborator

RomneyDa commented Sep 9, 2025

@meanderix relative paths (no leading slash) can be resolved using the resolveRelativePathInDir util

@RomneyDa
Copy link
Collaborator

RomneyDa commented Sep 9, 2025

@meanderix could you also add unit tests for this to validate expected behavior on various platforms etc?

@meanderix
Copy link
Contributor Author

@RomneyDa I'll take a look at that.

@Patrick-Erichsen
Copy link
Collaborator

Quick bump on this @meanderix , would be great to get it in!

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Sep 23, 2025
@meanderix
Copy link
Contributor Author

@Patrick-Erichsen @RomneyDa I've refactored the code a bit and added tests. Let me know what you think.

@Patrick-Erichsen
Copy link
Collaborator

This worked for me locally, there are a few merge conflicts now unfortunately. @meanderix if you can get those resolved this is good to merge!

@RomneyDa
Copy link
Collaborator

RomneyDa commented Oct 6, 2025

@meanderix the merge conflicts were ugly and caused by me. took a swing at fixing.

…eanderix/feature/mcp-make-workspace-root-default-cwd
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Oct 6, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 6, 2025
@RomneyDa RomneyDa merged commit 8292fbc into continuedev:main Oct 6, 2025
54 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Oct 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2025
@sestinj
Copy link
Contributor

sestinj commented Oct 8, 2025

🎉 This PR is included in version 1.27.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor

sestinj commented Oct 12, 2025

🎉 This PR is included in version 1.24.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor

sestinj commented Oct 15, 2025

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer released size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants