Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't workingneeds reproneeds additional information to be able to reproduce bugneeds additional information to be able to reproduce bug
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
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
async def _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."""
if sse.event == "message":
try:
# potential changes here
if not sse.data:
logger.debug("Receiving a ping message")
# double check if directly return True is compatible or enough
return True
message = JSONRPCMessage.model_validate_json(sse.data)
logger.debug(f"SSE message: {message}")Python & MCP Python SDK
python version: 3.13
MCP SDK version: 1.11.0
Reacted by Néstor Morales Hernández and Matthias Matt
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds reproneeds additional information to be able to reproduce bugneeds additional information to be able to reproduce bug
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.