Fix MCP subprocess env: start from os.Environ(), append extras
The loop was calling append(os.Environ(), ...) on each iteration, discarding all but the last extra env var. Start cmd.Env from os.Environ() once, then append each configured key=value pair. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6c38a1147c
commit
d64e49e893
|
|
@ -21,8 +21,9 @@ func NewSTDIOTransport(command string, args []string, env map[string]string) *ST
|
|||
// Connect launches the subprocess and returns a connected Client.
|
||||
func (t *STDIOTransport) Connect() (*Client, error) {
|
||||
cmd := exec.Command(t.command, t.args...)
|
||||
cmd.Env = os.Environ()
|
||||
for k, v := range t.env {
|
||||
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", k, v))
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
|
|
|
|||
Reference in New Issue