Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 50 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"@google/generative-ai": "^0.18.0",
"@google-cloud/vertexai": "^1.9.3",
"@mistralai/mistralai": "^1.3.6",
"@modelcontextprotocol/sdk": "^1.0.1",
"@modelcontextprotocol/sdk": "^1.5.0",
"@types/clone-deep": "^4.0.4",
"@types/pdf-parse": "^1.1.4",
"@types/tmp": "^0.2.6",
Expand Down
12 changes: 12 additions & 0 deletions src/services/mcp/McpHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,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
Contributor

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.

})

transport.onerror = async (error) => {
Expand Down Expand Up @@ -266,6 +267,17 @@ export class McpHub {
}
}

private getDefaultCwd() {
const paths = vscode.workspace.workspaceFolders
if (paths?.length === 1) {
// In workspaces with a single folder, we can safely use it as the default CWD for MCP servers
return paths[0].uri.fsPath
}
// Otherwise we return undefined, which means the MCP process will be spawned with
// NodeJS default CWD, i.e. process.cwd()
return undefined
}

private appendErrorMessage(connection: McpConnection, error: string) {
const newError = connection.server.error ? `${connection.server.error}\n${error}` : error
connection.server.error = newError //.slice(0, 800)
Expand Down
Loading