From 009155e4aa4140c4830cdf306799bea24f76a6bd Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Tue, 24 Feb 2026 04:11:22 +0800 Subject: [PATCH] fix: scope env var warnings to the server being queried Previously, environment variables were substituted eagerly for the entire config at parse time, causing missing-var warnings/errors for ALL servers even when only one server was being queried. Now env var substitution is deferred to getServerConfig(), so warnings only appear for the server being accessed. Fixes #20 --- src/config.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index 99a4e25..135cfb5 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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, @@ -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); } /**