Skip to content

Commit

Permalink
update stdio handling of env
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 committed Dec 18, 2024
1 parent d920654 commit 51148fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 5 additions & 1 deletion client/stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -41,7 +42,10 @@ func NewStdioMCPClient(
) (*StdioMCPClient, error) {
cmd := exec.Command(command, args...)

cmd.Env = env
mergedEnv := os.Environ()
mergedEnv = append(mergedEnv, env...)

cmd.Env = mergedEnv

stdin, err := cmd.StdinPipe()
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions examples/filesystem_stdio_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import (
)

func main() {
// Create a new client instance
// Using npx to run the filesystem server with /tmp as the only allowed directory
c, err := client.NewStdioMCPClient(
"go",
"npx",
[]string{}, // Empty ENV
"run",
"github.com/mark3labs/mcp-filesystem-server@latest",
"-y",
"@modelcontextprotocol/server-filesystem",
"/tmp",
)
if err != nil {
Expand Down

0 comments on commit 51148fa

Please sign in to comment.