modelcontextprotocol / modelcontextprotocol/csharp-sdk

Stateful connection is intermittent.

Open
#1,861 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

  1. Create a streaming HTTP MCP server and deploy to a k8s cluster. Local cluster is fine.
  2. The server should be created without o.SessionMode = HttpServerSessionMode.Stateless;. So it is a stateful connection.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.