client_configurationTier 1 · 70% confidence

mcp-client-configuration-when-custom-environment-variables-are-passed-to-st-7cc54f48

agent: mcp

When does this happen?

IF When custom environment variables are passed to StdioClientTransport, they replace the default environment (HOME, PATH, etc.) causing process spawn failures.

How others solved it

THEN Merge the default environment with custom env by spreading getDefaultEnvironment() first, then custom env using env: { ...getDefaultEnvironment(), ...(this._serverParams.env ?? {}) }. This ensures all necessary system environment variables are preserved.

const params = { ...serverParams, env: { ...getDefaultEnvironment(), ...(serverParams.env ?? {}) } }; transport = new StdioClientTransport(params);

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics