Skip to content

GET endpoint for unsolicited messages is called in stateless mode #1518

@AndreaVielCGN

Description

@AndreaVielCGN

I'm developing a MCP client and a server. I noticed that if I'm in stateful mode on the server (Stateless = false) the client will make only a POST / call to initialize the server. However if I enable the stateless mode (Stateless = true) the client will make an additional GET / call (that will get a 405 error) to the server.

In debugging I noticed the GET call is coming from here

_getReceiveTask ??= ReceiveUnsolicitedMessagesAsync();

What I don't get is why the GET call is made only when stateless and how it is deciding that (since state is a feature of the server and not the client) and if it makes sense to do that at all since as far as I understand in stateless mode unsolicited messages aren't supported. I should be the opposite in principle

The Streamable HTTP client automatically reconnects its SSE event stream when the connection drops. This only applies to **stateful sessions**the GET event stream is how the server sends unsolicited messages to the client, and it requires an active session. Stream reconnection is separate from session expiry: reconnection recovers the event stream within an existing session, while the example above handles creating a new session after the server has terminated the old one.
.

If that matters the client is set to TransportMode = HttpTransportMode.StreamableHttp avoiding SSE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproInsufficient information to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions