Skip to content

Default Environment should be appended with custom env's passed to client (instead of replacing) #216

Open
@Pdash-exceeds

Description

@Pdash-exceeds

Describe the bug
In this line

env: this._serverParams.env ?? getDefaultEnvironment(),

To Reproduce
Steps to reproduce the behavior:

  1. Connect a stdio client without custom env (works)
  2. Connect the same client with custom env (fails because HOME, PATH and other default envs are missing when spawning the process)

Expected behavior
Both cases should pass.
env: { ...getDefaultEnvironment(), ...(this._serverParams.env ?? {}) },

Logs
file:///Users/pradeeptadash/langchain_mcp/node_modules/@langchain/mcp-adapters/dist/src/client.js:407
throw new MCPClientError(Failed to connect to stdio server "${serverName}": ${error}, serverName);
^

MCPClientError: Failed to connect to stdio server "linear-server": Error: spawn npx ENOENT
at MultiServerMCPClient.initializeStdioConnection (file:///Users/pradeeptadash/langchain_mcp/node_modules/@langchain/mcp-adapters/dist/src/client.js:407:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async MultiServerMCPClient.initializeConnections (file:///Users/pradeeptadash/langchain_mcp/node_modules/@langchain/mcp-adapters/dist/src/client.js:371:17)

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions