This change updates the MCP client stdio JSON decoder to correctly handle both Unix (`\n`) and Windows (`\r\n`) line endings. Fixes #664 Co-authored-by: qysz <i_zf@qq.com>
This commit is contained in:
parent
2ce44d45e9
commit
1bec3c60a0
1 changed files with 7 additions and 1 deletions
|
|
@ -380,7 +380,8 @@ func newIOConn(rwc io.ReadWriteCloser) *ioConn {
|
|||
var tr [1]byte
|
||||
if n, readErr := dec.Buffered().Read(tr[:]); n > 0 {
|
||||
// If read byte is not a newline, it is an error.
|
||||
if tr[0] != '\n' {
|
||||
// Support both Unix (\n) and Windows (\r\n) line endings.
|
||||
if tr[0] != '\n' && tr[0] != '\r' {
|
||||
err = fmt.Errorf("invalid trailing data at the end of stream")
|
||||
}
|
||||
} else if readErr != nil && readErr != io.EOF {
|
||||
|
|
|
|||
Loading…
Reference in a new issue