Skip to content

Commit f1bd11f

Browse files
committed
mcp supports cwd config and defaults to workspace cwd
1 parent c4d1d34 commit f1bd11f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/services/mcp/McpHub.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const createServerTypeSchema = () => {
6363
type: z.enum(["stdio"]).optional(),
6464
command: z.string().min(1, "Command cannot be empty"),
6565
args: z.array(z.string()).optional(),
66+
cwd: z.string().default(vscode.workspace.workspaceFolders?.at(0)?.uri.fsPath ?? process.cwd()),
6667
env: z.record(z.string()).optional(),
6768
// Ensure no SSE fields are present
6869
url: z.undefined().optional(),
@@ -79,7 +80,7 @@ const createServerTypeSchema = () => {
7980
url: z.string().url("URL must be a valid URL format"),
8081
headers: z.record(z.string()).optional(),
8182
// Ensure no stdio fields are present
82-
command: z.undefined().optional(),
83+
command: z.undefined(),
8384
args: z.undefined().optional(),
8485
env: z.undefined().optional(),
8586
})
@@ -314,7 +315,7 @@ export class McpHub {
314315
mcpSettingsFilePath,
315316
`{
316317
"mcpServers": {
317-
318+
318319
}
319320
}`,
320321
)
@@ -427,6 +428,7 @@ export class McpHub {
427428
transport = new StdioClientTransport({
428429
command: config.command,
429430
args: config.args,
431+
cwd: config.cwd,
430432
env: {
431433
...config.env,
432434
...(process.env.PATH ? { PATH: process.env.PATH } : {}),

0 commit comments

Comments
 (0)