-
Notifications
You must be signed in to change notification settings - Fork 286
Description
Describe the bug
When using the MCP client on Windows, connecting to a Python MCP server (using mcp-python) fails immediately during initialize with the following error: calling "initialize": invalid trailing data at the end
of stream
To Reproduce
The following code can be used to reproduce the problem:
func main() {
ctx := context.Background()
// Create a new client, with no features.
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
// Connect to a server over stdin/stdout.
transport := &mcp.CommandTransport{Command: exec.Command("uvx", "mcp-server-fetch")}
session, err := client.Connect(ctx, transport, nil)
if err != nil {
log.Fatal(err)
}
defer session.Close()
}
Expected behavior
The Go MCP client should successfully communicate with the Python MCP server on Windows via stdio.
Additional context
This issue is likely related to #192. The original fix handled only \n as a valid newline delimiter, and fails when encountering Windows-style \r\n, causing the Go client to treat it as trailing data and throw an error.
If possible, could this be updated so that the check allows both \n and \r? For example:
if tr[0] != '\n' && tr[0] != '\r' {
This would make the stdio framing compatible with Windows (\r\n) while preserving existing behavior on Unix-like systems.