modelcontextprotocol / modelcontextprotocol/csharp-sdk
Stateful connection is intermittent.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
Description
Describe the bug
Without o.SessionMode = HttpServerSessionMode.Stateless; or with the line commented out, the connection sometimes succeed and sometimes failed. I don't believe this should cause the connection to fail at all since otherwise, the product won't be able to support the stateful connection as claimed in https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/concepts/transports/transports.md#streamable-http-server-aspnet-core
Set SessionMode = HttpServerSessionMode.Stateful explicitly when your server needs stateful sessions for unsolicited notifications, resource subscriptions, or per-client isolation.
and therefore, it is a BUG.
To Reproduce
Steps to reproduce the behavior:
- Create a streaming HTTP MCP server and deploy to a k8s cluster. Local cluster is fine.
- The server should be created without
o.SessionMode = HttpServerSessionMode.Stateless;. So it is a stateful connection. - Try to connect to the service either from Postman MCP client OR
npx @modelcontextprotocol/inspector
Expected behavior
Successful connection 100%
Logs
If applicable, add logs to help explain your problem.
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read docs/concepts/transports/transports.md at the Streamable HTTP server section, then reproduce the stateful setup in a local Kubernetes cluster using Postman MCP or @modelcontextprotocol/inspector. Compare behavior with and without HttpServerSessionMode.Stateless; done means the stateful server connects successfully and consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, kubernetes
- Domain
- api, backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100