Closed
Description
Describe the bug
When add env
in StdioClientTransport
, it will be crashed.
To Reproduce
Steps to reproduce the behavior:
new StdioClientTransport({
command: "npx",
args: ["-y", "@modelcontextprotocol/server-github"],
env: {
"GITHUB_PERSONAL_ACCESS_TOKEN": "MYTOKEN"
}
}),
Will see this error:
err: {
"type": "McpError",
"message": "MCP error -32000: Connection closed",
"stack":
McpError: MCP error -32000: Connection closed
at Client._onclose (/home/fengyu/projects/DTeam-Top/eliza-mcp-plugin/node_modules/.pnpm/@[email protected]/node_modules/@modelcontextprotocol/sdk/src/shared/protocol.ts:260:19)
at StdioClientTransport._transport.onclose (/home/fengyu/projects/DTeam-Top/eliza-mcp-plugin/node_modules/.pnpm/@[email protected]/node_modules/@modelcontextprotocol/sdk/src/shared/protocol.ts:233:12)
at ChildProcess.<anonymous> (/home/fengyu/projects/DTeam-Top/eliza-mcp-plugin/node_modules/.pnpm/@[email protected]/node_modules/@modelcontextprotocol/sdk/src/client/stdio.ts:145:21)
at ChildProcess.emit (node:events:518:28)
at maybeClose (node:internal/child_process:1101:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5)
"code": -32000,
"name": "McpError"
}
But remove env
and put it into environment variables, it works.
Expected behavior
A clear and concise description of what you expected to happen.
env
should working