File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package mcp
44import (
55 "context"
66 "fmt"
7+ "io"
78 "os"
89 "os/exec"
910 "path/filepath"
@@ -101,6 +102,15 @@ func (c *Client) connectStdio(ctx context.Context) error {
101102 if err != nil {
102103 return fmt .Errorf ("failed to create stdio MCP client: %w" , err )
103104 }
105+
106+ // Drain the server's stderr in a background goroutine to prevent the
107+ // subprocess from blocking on a full pipe buffer. On Windows the default
108+ // pipe buffer is ~4 KB; once it fills, any write to stderr blocks the
109+ // entire Node.js event loop, causing all subsequent tool calls to hang.
110+ if stderr , ok := mcpclient .GetStderr (client ); ok {
111+ go func () { _ , _ = io .Copy (io .Discard , stderr ) }()
112+ }
113+
104114 c .inner = client
105115 c .serverCmd = spawnedCmd
106116
You can’t perform that action at this time.
0 commit comments