Skip to content

SseClientTransport compatibility issue with non-compliant MCP SSE services #186

@loocor

Description

@loocor

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:

  1. Use rmcp SDK's SseClientTransport to connect to modelscope.cn's SSE service
  2. Initial HTTP GET request succeeds (returns 200 OK)
  3. SseClientTransport waits for the "endpoint" event
  4. Since modelscope.cn doesn't send an "endpoint" event as expected, the connection never completes
  5. 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 received

Expected 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:

  1. Provide an option to skip waiting for the "endpoint" event
  2. Or use a default endpoint path (like "/messages") after timing out waiting for the "endpoint" event
  3. 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

  1. 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();
};
  1. 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.

  2. 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.

  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions