-
Notifications
You must be signed in to change notification settings - Fork 401
Description
Describe the bug
The SseClientTransport implementation in the rmcp SDK has compatibility issues that prevent connections to SSE services that don't fully comply with the MCP specification (such as modelscope.cn). Specifically, the SseClientTransport::start_with_client function, after establishing an SSE connection, mandatorily waits for an event named "endpoint". Some services may not send this event or use a different format, causing the connection to never complete.
To Reproduce
Steps to reproduce:
- Use rmcp SDK's SseClientTransport to connect to modelscope.cn's SSE service
- Initial HTTP GET request succeeds (returns 200 OK)
- SseClientTransport waits for the "endpoint" event
- Since modelscope.cn doesn't send an "endpoint" event as expected, the connection never completes
- The connection eventually times out or fails
Code example:
let connection_result = SseClientTransport::start("https://mcp.api-inference.modelscope.cn/sse/{id}").await;
// Connection fails because no "endpoint" event is receivedExpected behavior
SseClientTransport should be able to adapt to different SSE service implementations, including those that don't fully comply with the MCP specification. Ideally, it should:
- Provide an option to skip waiting for the "endpoint" event
- Or use a default endpoint path (like "/messages") after timing out waiting for the "endpoint" event
- Or implement an automatic fallback mechanism that tries different connection strategies
Logs
2025-05-18T06:35:29.051798Z WARN mcpmate::http::pool::connection: Failed to trigger connection to server 'fetch': Failed to connect to server: Client error: HTTP status client error (404 Not Found) for url (https://mcp.api-inference.modelscope.cn/sse/{id}/messages/?session_id={session_id})
2025-05-18T06:35:44.587829Z WARN mcpmate::http::pool::connection: Failed to trigger connection to server 'thinking': Failed to connect to server: Client error: HTTP status client error (404 Not Found) for url (https://mcp.api-inference.modelscope.cn/sse/{id}/messages/?session_id={session_id})
Additional context
- Through code analysis, we found that the issue is in the rmcp SDK's SseClientTransport::start_with_client function (sdk/crates/rmcp/src/transport/sse_client.rs lines 121-132):
let mut sse_stream = client.get_stream(config.uri.clone(), None, None).await?;
// wait the endpoint event
let endpoint = loop {
let sse = sse_stream
.next()
.await
.ok_or(SseTransportError::UnexpectedEndOfStream)??;
let Some("endpoint") = sse.event.as_deref() else {
continue;
};
break sse.data.unwrap_or_default();
};-
This code mandatorily waits for an event named "endpoint", but some services (like modelscope.cn) may not send this event or use a different format.
-
We tried various solutions, including modifying the URL format and implementing an automatic switching mechanism, but due to limitations in the rmcp SDK's internal implementation, these methods couldn't fully resolve the issue.
-
Suggested solutions:
- Modify the rmcp SDK to add an option to skip waiting for the "endpoint" event
- Or create a custom SseClientTransport implementation specifically for non-standard services
- Or implement a more flexible fallback mechanism in SseClientTransport