fix(skill-mcp): always inherit process.env for MCP servers

- Always merge parent process.env when spawning MCP child processes
- Overlay config.env on top if present (for skill-specific overrides)
- Fixes issue where skills without explicit env: block started with zero environment variables
- Adds 2 tests for env inheritance behavior

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2026-01-02 16:07:33 +09:00
parent 4628d52025
commit 1c13308d8c
2 changed files with 56 additions and 4 deletions
+6 -4
View File
@@ -55,18 +55,20 @@ export class SkillMcpManager {
const command = config.command
const args = config.args || []
// Always inherit parent process environment
const mergedEnv: Record<string, string> = {}
for (const [key, value] of Object.entries(process.env)) {
if (value !== undefined) mergedEnv[key] = value
}
// Overlay with skill-specific env vars if present
if (config.env) {
for (const [key, value] of Object.entries(process.env)) {
if (value !== undefined) mergedEnv[key] = value
}
Object.assign(mergedEnv, config.env)
}
const transport = new StdioClientTransport({
command,
args,
env: config.env ? mergedEnv : undefined,
env: mergedEnv,
})
const client = new Client(