-
Notifications
You must be signed in to change notification settings - Fork 550
Open
Description
io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider.WebMvcMcpSessionTransport#sendMessage
this sseBuilder is not thread-safe,when a client makes a large number of concurrent requests in a single moment, it triggers the writing of data to the same session ID, causing the SSE to be out of order.
@Override
public Mono<Void> sendMessage(McpSchema.JSONRPCMessage message) {
return Mono.fromRunnable(() -> {
try {
String jsonText = objectMapper.writeValueAsString(message);
sseBuilder.id(sessionId).event(MESSAGE_EVENT_TYPE).data(jsonText);
logger.debug("Message sent to session {}", sessionId);
}
catch (Exception e) {
logger.error("Failed to send message to session {}: {}", sessionId, e.getMessage());
sseBuilder.error(e);
}
});
}
Metadata
Metadata
Assignees
Labels
No labels