You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Streamable Http transport handle ping message #1146
code in src/mcp/client/streamable_http.py:162 validates the payload from incoming SSE messages.
However, on the server side, EventSourceResponse is used, which periodically sends ping message. These ping messages will cause client side parsing message error.
When SSE is used to stream logs, these ping messages trigger unwanted behavior, such as flushing logs unnecessarily. Currently, there doesn’t appear to be a configuration option to disable the ping messages or adjust their interval.
As a potential improvement, the client could check if the incoming message has an empty data field before validation. If the data is empty, the client can treat it as a ping message and safely ignore it.
Example Code
asyncdef_handle_sse_event(
self,
sse: ServerSentEvent,
read_stream_writer: StreamWriter,
original_request_id: RequestId|None=None,
resumption_callback: Callable[[str], Awaitable[None]] |None=None,
is_initialization: bool=False,
) ->bool:
"""Handle an SSE event, returning True if the response is complete."""ifsse.event=="message":
try:
# potential changes hereifnotsse.data:
logger.debug("Receiving a ping message")
# double check if directly return True is compatible or enoughreturnTruemessage=JSONRPCMessage.model_validate_json(sse.data)
logger.debug(f"SSE message: {message}")
Hi @Gujiawei-Edinburgh thanks for submitting this issue, could you provide a snippet or minimal example that demonstrates the pings causing an issue? By default there shouldn't be anything broken by sending pings.
Error parsing SSE message
Traceback (most recent call last):
File "/path/to/.venv/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 164, in _handle_sse_event
message = JSONRPCMessage.model_validate_json(sse.data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/.venv/lib/python3.12/site-packages/pydantic/main.py", line 744, in model_validate_json
return cls.__pydantic_validator__.validate_json(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for JSONRPCMessage
Invalid JSON: EOF while parsing a value at line 1 column 0 [type=json_invalid, input_value='', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/json_invalid
Process finished with exit code 0
This fails because sse.data is an empty string. Since the everything MCP Server is a reference implementation I would expect that this should not fail and that this is a standard and expected case.
Activity
raptium commentedon Aug 22, 2025
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
The ping mesage is just a comment, so the client should ignore it at all.
felixweinberger commentedon Oct 3, 2025
Hi @Gujiawei-Edinburgh thanks for submitting this issue, could you provide a snippet or minimal example that demonstrates the pings causing an issue? By default there shouldn't be anything broken by sending pings.
meffmadd commentedon Nov 26, 2025
I am getting the exact same error! I have
mcpversion1.22.0. Here is an example:everythingMCP server:npx @modelcontextprotocol/server-everything@2025.11.25 streamableHttpThis fails because
sse.datais an empty string. Since theeverythingMCP Server is a reference implementation I would expect that this should not fail and that this is a standard and expected case.