Skip to content

Streamable HTTP handler returns 500 instead of 400 when body read fails #816

@roncodingenthusiast

Description

@roncodingenthusiast

Problem

In mcp/streamable.go around line 376, when io.ReadAll(req.Body) fails during stateless mode initialization, the handler returns http.StatusInternalServerError (500).

However, body read failures are almost always caused by client-side issues:

  • Client disconnected before sending full body
  • Network timeout/interruption
  • Connection reset

Returning 500 is misleading because it suggests a server error when the issue is on the client side.

Expected Behavior

Return http.StatusBadRequest (400) instead, consistent with the similar check in servePOST which already returns 400.

Impact

Users monitoring their MCP servers see 500 errors in telemetry that appear to be server bugs, when they're actually client disconnections. This causes unnecessary investigation and alert fatigue.

Metadata

Metadata

Labels

ready for workHas enough information to start

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions