Skip to content

Commit 261a63c

Browse files
authored
mcp: don't panic on bad JSON RPC input (#177)
Log internal errors from the jsonprc2 package, instead of panicking. Fixes #175.
1 parent 6e5ba95 commit 261a63c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mcp/transport.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13+
"log"
1314
"net"
1415
"os"
1516
"sync"
@@ -120,6 +121,7 @@ func connect[H handler](ctx context.Context, t Transport, b binder[H]) (H, error
120121
OnDone: func() {
121122
b.disconnect(h)
122123
},
124+
OnInternalError: func(err error) { log.Printf("jsonrpc2 error: %v", err) },
123125
})
124126
assert(preempter.conn != nil, "unbound preempter")
125127
h.setConn(conn)

0 commit comments

Comments
 (0)