File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,13 @@ func NewStdioMCPClient(
31
31
32
32
// GetStderr returns a reader for the stderr output of the subprocess.
33
33
// This can be used to capture error messages or logs from the subprocess.
34
- //
35
- // Note: This method only works with stdio transport, or it will panic.
36
- func GetStderr (c * Client ) io.Reader {
34
+ func GetStderr (c * Client ) (io.Reader , bool ) {
37
35
t := c .GetTransport ()
38
- stdio := t .(* transport.Stdio )
39
- return stdio .Stderr ()
36
+
37
+ stdio , ok := t .(* transport.Stdio )
38
+ if ! ok {
39
+ return nil , false
40
+ }
41
+
42
+ return stdio .Stderr (), true
40
43
}
Original file line number Diff line number Diff line change @@ -47,7 +47,13 @@ func TestStdioMCPClient(t *testing.T) {
47
47
wg .Add (1 )
48
48
go func () {
49
49
defer wg .Done ()
50
- dec := json .NewDecoder (GetStderr (client ))
50
+
51
+ stderr , ok := GetStderr (client )
52
+ if ! ok {
53
+ return
54
+ }
55
+
56
+ dec := json .NewDecoder (stderr )
51
57
for {
52
58
var record map [string ]any
53
59
if err := dec .Decode (& record ); err != nil {
You can’t perform that action at this time.
0 commit comments