Skip to content

stdio backends have no cwd support — requires bash wrapper workaround #5

@arek-e

Description

@arek-e

Feature request / Bug

Many MCP servers use relative paths in their args (e.g. npx tsx ./libs/design-system-mcp/src/index.ts, npx nx-mcp@latest .). Without a cwd field, mcpx always spawns them from its own working directory, which is wrong.

The only workaround today is an ugly bash wrapper:

{
  "design_system": {
    "transport": "stdio",
    "command": "bash",
    "args": ["-c", "cd /abs/path/to/project && exec npx tsx ./libs/design-system-mcp/src/index.ts"]
  }
}

Fix

StdioClientTransport already accepts a cwd option. The change is two lines:

src/config.ts — add field to BackendConfig:

export interface BackendConfig {
  transport: "stdio" | "http" | "openapi";
  command?: string;
  args?: string[];
  cwd?: string;          // <-- add this
  env?: Record<string, string>;
  // ... rest unchanged
}

src/backends.ts — pass it to the transport:

const transport = new StdioClientTransport({
  command: config.command,
  args: config.args ?? [],
  env: { ...process.env, ...config.env } as Record<string, string>,
  cwd: config.cwd,       // <-- add this
});

This lets users write clean configs:

{
  "design_system": {
    "transport": "stdio",
    "command": "npx",
    "args": ["tsx", "./libs/design-system-mcp/src/index.ts"],
    "cwd": "/path/to/project"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions