Skip to content

Set CWD of MCP server for single-root workspaces #964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

gusbicalho
Copy link

@gusbicalho gusbicalho commented Feb 12, 2025

Description

It's useful to have the MCP process started in the workspace directory, so the process can rely on local configuration files.

For example, I use ASDF to manage NodeJS version in a project. By setting the CWD to be the current workspace, an MCP that runs npx will use the node version defined for the project.

This is a very recent addition to the @modelcontextprotocol/sdk so I updated it to version 1.5.0.

When we do not specify the CWD, the MCP server is spawned at process.cwd(), which (in my machine at least) returns /.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • ? Breaking change (fix or feature that would cause existing functionality to not work as expected):
    • This has the potential to change behaviour, if some MCP out there was relying on being run at the / path.
    • This seems unlikely, but if we want to be really strict about making this non-breaking, we could keep the current behaviour if config.cwd is undefined. We would then only apply the new behaviour if config.cwd === <some_special_value> e.g. "{workspaceDir}".
  • This change requires a documentation update

How Has This Been Tested?

Tested the extension locally and found that it now starts an MCP with the correct CWD.

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Sets CWD for MCP servers to workspace directory in single-root workspaces and updates SDK to version 1.5.0.

  • Behavior:
    • Sets CWD for MCP servers to workspace directory in single-root workspaces in McpHub.ts.
    • Defaults to process.cwd() if no workspace or multiple workspaces.
  • Dependencies:
    • Updates @modelcontextprotocol/sdk to version 1.5.0 in package.json.

This description was created by Ellipsis for 00e9c7b. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented Feb 12, 2025

⚠️ No Changeset found

Latest commit: bb04dde

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -170,6 +170,7 @@ export class McpHub {
// ...(process.env.NODE_PATH ? { NODE_PATH: process.env.NODE_PATH } : {}),
},
stderr: "pipe", // necessary for stderr to be available
cwd: config.cwd ?? this.getDefaultCwd(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the configuration schema to document the new 'cwd' option explicitly.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 25, 2025
@hannesrudolph hannesrudolph moved this to To triage in Roo Code Roadmap Mar 5, 2025
@hannesrudolph hannesrudolph moved this from To triage to PR - Needs Approval in Roo Code Roadmap Mar 6, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Needs Review] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs daniel-lxs moved this from TEMP to PR [Needs Review] in Roo Code Roadmap May 26, 2025
@daniel-lxs
Copy link
Collaborator

Hey @gusbicalho, Thank you for your contribution. We genuinely apologize for taking so long to give you any feedback on your PR, we are working hard to prevent this from happening again.

We are closing this PR because it seems that this feature is already implemented into Roo Code.

We've now shifted to a clearer issue-first workflow to avoid this kind of situation going forward. Please create an issue first for any future contributions, as outlined there.

Thank you for your patience. We would be happy to see more of your contributions in the future.

@daniel-lxs daniel-lxs closed this May 27, 2025
@github-project-automation github-project-automation bot moved this from Needs Preliminary Review to Done in Roo Code Roadmap May 27, 2025
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants