mcp: don't panic on bad JSON RPC input (#177)

Log internal errors from the jsonprc2 package, instead of panicking.

Fixes #175.
This commit is contained in:
Jonathan Amsterdam 2025-07-28 10:29:59 -04:00 • committed by GitHub
commit 261a63ccc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"io"
"log"
"net"
"os"
"sync"
@ -120,6 +121,7 @@ func connect[H handler](ctx context.Context, t Transport, b binder[H]) (H, error
OnDone: func() {
b.disconnect(h)
},
OnInternalError: func(err error) { log.Printf("jsonrpc2 error: %v", err) },
})
assert(preempter.conn != nil, "unbound preempter")
h.setConn(conn)