Skip to content

Commit 51148fa

Browse files
committed
update stdio handling of env
1 parent d920654 commit 51148fa

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

client/stdio.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"io"
9+
"os"
910
"os/exec"
1011
"sync"
1112
"sync/atomic"
@@ -41,7 +42,10 @@ func NewStdioMCPClient(
4142
) (*StdioMCPClient, error) {
4243
cmd := exec.Command(command, args...)
4344

44-
cmd.Env = env
45+
mergedEnv := os.Environ()
46+
mergedEnv = append(mergedEnv, env...)
47+
48+
cmd.Env = mergedEnv
4549

4650
stdin, err := cmd.StdinPipe()
4751
if err != nil {

examples/filesystem_stdio_client/main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import (
1212
)
1313

1414
func main() {
15-
// Create a new client instance
16-
// Using npx to run the filesystem server with /tmp as the only allowed directory
1715
c, err := client.NewStdioMCPClient(
18-
"go",
16+
"npx",
1917
[]string{}, // Empty ENV
20-
"run",
21-
"github.com/mark3labs/mcp-filesystem-server@latest",
18+
"-y",
19+
"@modelcontextprotocol/server-filesystem",
2220
"/tmp",
2321
)
2422
if err != nil {

0 commit comments

Comments
 (0)