Skip to content

Can't connect to SSE server on preview 10 #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nstayte opened this issue Apr 22, 2025 · 6 comments
Open

Can't connect to SSE server on preview 10 #340

nstayte opened this issue Apr 22, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@nstayte
Copy link

nstayte commented Apr 22, 2025

Describe the bug
When using Windsurf MCP, it gets an error.
Failed to start mcp sse client: Endpoint origin does not match connection origin localhost:5000

This doesn't happen in preview8, but happens in 9 and 10.
If you run the sample server on the latest main there is no error, but if you run the latest tag preview 10 it has the error.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the csharp-sdk repo
  2. Checkout v0.1.0-preview tag
  3. Run the AspNetCoreSseServer
  4. Add this to the Windsurf mcp_config.json
    "test-server": { "serverUrl": "http://localhost:5000/sse" }
  5. Refresh the MCP servers in Windsurf
  6. Get the error
  7. Checkout main and restart the ASP server
  8. Refresh the MCP servers in Windsurf the error goes away and shows the tools
@nstayte nstayte added the bug Something isn't working label Apr 22, 2025
@FoxitJohnny
Copy link

The same issue here. Running the csharp-sdk\samples\AspNetCoreSseServer on preview.10, the client will report 406. Rolling back to preview.9 with the same codebase works fine.

System.Net.Http.HttpRequestException: 'Response status code does not indicate success: 406 (Not Acceptable).'

@halter73
Copy link
Contributor

This doesn't happen in preview8, but happens in 9 and 10.

Rolling back to preview.9 with the same codebase works fine.

We seem to be getting some conflicting reports here. There have been a couple of changes to MapMcp() in the recently release previews that might be causing different problems for different people.

In preview.9, we started emitting "messages" instead of "/messages" for the endpoint event. Preview 8 and earlier:

event: endpoint
data: /messages

vs. preview 9 and 10:

event: endpoint
data: messages

The reason the behavior changed in previews 9 and 10 is to better handle custom patterns passed to MapMcp like MapMcp("mymcpserver") (#280). A non-root-relative URL should be valid, so it's probably a bug in the client if it broke between preview 8 and preview 9. https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references

@nstayte It might be worth leaving feed feedback with Windsurf asking them to fix the relative URL handling of their SSE MCP client.

However, in preview.11, we should start emitting a root-relative URL again, but this time correctly include any necessary path prefixes that should fix these buggy clients. #323 (comment)

System.Net.Http.HttpRequestException: 'Response status code does not indicate success: 406 (Not Acceptable).'

In preview 10, we changed the primary route for MapMcp() from SSE to Streamable HTTP (#330). The primary MapMcp() endpoint will no longer accept plain SSE GET reequests, however you can continue to point your SSE client to the "/sse" endpoint.

So, this is broken in preview 10:

var client = McpClientFactory.CreateAsync(
    new SseClientTransport(new()
    {
        Endpoint = new("http://localhost:3001"), // Returns 406 (Not Acceptable)!
    }));

But this works:

var client = McpClientFactory.CreateAsync(
    new SseClientTransport(new()
    {
        Endpoint = new("http://localhost:3001/sse"), // Still works!
    }));

I plan to implement a new StreamableHttpClientTransport that will work with the primary route by the end of week.

@szatixx
Copy link

szatixx commented Apr 23, 2025

I have similar issue, both with preview 9 and 10. Here are the details: #320

I am trying to connect with modelcontextprotocol/inspector.

@halter73
Copy link
Contributor

@szatixx Are you trying to connect to the /sse endpoint? I think the inspector's Streamable HTTP support still needs some work. modelcontextprotocol/inspector#339 is currently open to fix some known issues.

@nstayte
Copy link
Author

nstayte commented Apr 26, 2025

@nstayte It might be worth leaving feed feedback with Windsurf asking them to fix the relative URL handling of their SSE MCP client.

I've logged this with Windsurf as well.

@szatixx
Copy link

szatixx commented May 6, 2025

@halter73 The weird thing is that I have OpenAPI in the aps.net pipeline, and it doesn't shows any http endpoint (except the one I made). Here is my full code: https://gist.github.com/szatixx/6149e99f80bf02ce21d5decd3a29be20

I was trying to figure out for hours where I make the mistake, but it looks like for me that it should work.
If modelcontextprotocol/inspector is still under development, do you know about any alternatives? (Easy to use tool, to test my code during development.)

Thanks
Attila

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants