mcp-go icon indicating copy to clipboard operation
mcp-go copied to clipboard

Response message due to Parse Error has invalid id

Open emicklei opened this issue 8 months ago • 2 comments

When a MCP server is misbehaving (typically during development) and there are issues with message processing or response writing, an Error response is written, see

https://github.com/mark3labs/mcp-go/blob/edda393a1a231aefaaef41086ba7344e30c6b559/server/stdio.go#L233

(v0.23.0)

The createErrorResponse is called with a nil for id which is invalid according to the specification ; this causes errors in the client (when that is validating the message) and therefore hides the actual cause.

emicklei avatar Apr 23 '25 14:04 emicklei

According to https://modelcontextprotocol.io/docs/concepts/transports the id is either a number or string, maybe better to pass an empty string here.

emicklei avatar Apr 24 '25 08:04 emicklei

however, the json rpc2 spec says null is allowed: https://www.jsonrpc.org/specification#request_object

so maybe this issue is obsolete and it is the client not handling it correctly.

emicklei avatar May 01 '25 10:05 emicklei