Set CWD of MCP server for single-root workspaces #964
+63
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
/
path.config.cwd
is undefined. We would then only apply the new behaviour ifconfig.cwd === <some_special_value>
e.g."{workspaceDir}"
.How Has This Been Tested?
Tested the extension locally and found that it now starts an MCP with the correct CWD.
Checklist:
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.
McpHub.ts
.process.cwd()
if no workspace or multiple workspaces.@modelcontextprotocol/sdk
to version 1.5.0 inpackage.json
.This description was created by
for 00e9c7b. It will automatically update as commits are pushed.