Merge pull request #7709 from fbricon/fix-mcp-env
fix: use common process.env values to launch MCP
This commit is contained in:
commit
2883f91ca0
1 changed files with 12 additions and 1 deletions
|
|
@ -38,6 +38,8 @@ const WINDOWS_BATCH_COMMANDS = [
|
|||
"bunx",
|
||||
];
|
||||
|
||||
const COMMONS_ENV_VARS = ["HOME", "USER", "USERPROFILE", "LOGNAME", "USERNAME"];
|
||||
|
||||
function is401Error(error: unknown) {
|
||||
return (
|
||||
(error instanceof SseError && error.code === 401) ||
|
||||
|
|
@ -464,7 +466,16 @@ class MCPConnection {
|
|||
private async constructStdioTransport(
|
||||
options: InternalStdioMcpOptions,
|
||||
): Promise<StdioClientTransport> {
|
||||
const env: Record<string, string> = options.env ? { ...options.env } : {};
|
||||
const commonEnvVars: Record<string, string> = Object.fromEntries(
|
||||
COMMONS_ENV_VARS.filter((key) => process.env[key] !== undefined).map(
|
||||
(key) => [key, process.env[key] as string],
|
||||
),
|
||||
);
|
||||
|
||||
const env = {
|
||||
...commonEnvVars,
|
||||
...(options.env ?? {}),
|
||||
};
|
||||
|
||||
if (process.env.PATH !== undefined) {
|
||||
// Set the initial PATH from process.env
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue