mcp supports cwd config and defaults to workspace cwd (#2171)

* mcp supports cwd config and defaults to workspace cwd

* clean up

* Update src/services/mcp/McpHub.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
jdavis 2025-04-03 15:08:21 -04:00 committed by GitHub
parent e7a1db83c0
commit b38b40656c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,6 +63,7 @@ const createServerTypeSchema = () => {
type: z.enum(["stdio"]).optional(),
command: z.string().min(1, "Command cannot be empty"),
args: z.array(z.string()).optional(),
cwd: z.string().default(() => vscode.workspace.workspaceFolders?.at(0)?.uri.fsPath ?? process.cwd()),
env: z.record(z.string()).optional(),
// Ensure no SSE fields are present
url: z.undefined().optional(),
@ -314,7 +315,7 @@ export class McpHub {
mcpSettingsFilePath,
`{
"mcpServers": {
}
}`,
)
@ -427,6 +428,7 @@ export class McpHub {
transport = new StdioClientTransport({
command: config.command,
args: config.args,
cwd: config.cwd,
env: {
...config.env,
...(process.env.PATH ? { PATH: process.env.PATH } : {}),