fix(skill-mcp-manager): filter merged MCP env before spawn

Apply env filtering after customEnv merge to prevent filtered
variables (API keys, secrets) from being reintroduced through
custom environment configuration.
This commit is contained in:
YeonGyu-Kim
2026-04-02 14:52:02 +09:00
parent a637cca702
commit 4fe49a6151
2 changed files with 30 additions and 7 deletions
@@ -28,18 +28,22 @@ export const EXCLUDED_ENV_PATTERNS: RegExp[] = [
export function createCleanMcpEnvironment(
customEnv: Record<string, string> = {}
): Record<string, string> {
const cleanEnv: Record<string, string> = {}
const mergedEnv: Record<string, string> = {}
for (const [key, value] of Object.entries(process.env)) {
if (value === undefined) continue
mergedEnv[key] = value
}
Object.assign(mergedEnv, customEnv)
const cleanEnv: Record<string, string> = {}
for (const [key, value] of Object.entries(mergedEnv)) {
const shouldExclude = EXCLUDED_ENV_PATTERNS.some((pattern) => pattern.test(key))
if (!shouldExclude) {
cleanEnv[key] = value
}
}
Object.assign(cleanEnv, customEnv)
return cleanEnv
}