Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,17 @@ export async function loadConfig(
}
}

// Substitute environment variables
config = substituteEnvVarsInObject(config);
// Environment variable substitution is deferred to getServerConfig()
// so that warnings/errors only appear for the server being accessed.

return config;
}

/**
* Get a specific server config by name
* Get a specific server config by name.
*
* Environment variables are substituted lazily here so that missing-var
* warnings are scoped to the server being queried (fixes #20).
*/
export function getServerConfig(
config: McpServersConfig,
Expand All @@ -514,7 +517,7 @@ export function getServerConfig(
const available = Object.keys(config.mcpServers);
throw new Error(formatCliError(serverNotFoundError(serverName, available)));
}
return server;
return substituteEnvVarsInObject(server);
}

/**
Expand Down