modelcontextprotocol / modelcontextprotocol/csharp-sdk
Alternative to `RunSessionHandler` for accessing MCP servers
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
Description
Now that RunSessionHandler has been marked as experimental, what is the correct way to access the MCP servers in order to send notifications at a later time?
We currently have:
var mcpServers = new ConcurrentDictionary<string, McpServer>();
options.RunSessionHandler = async (_, mcpServer, token) =>
{
if (mcpServer.SessionId == null)
{
// There is no sessionId if serverOptions.Stateless is true.
await mcpServer.RunAsync(token);
return;
}
try
{
mcpServers[mcpServer.SessionId] = mcpServer;
await mcpServer.RunAsync(token);
}
finally
{
// This code runs when the session ends.
mcpServers.TryRemove(mcpServer.SessionId, out var _);
}
};
We are then able to send notifications to the active servers.
(initially posted 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
Start by reviewing the RunSessionHandler and McpServer APIs, especially McpServer.SessionId and RunAsync, and compare them with the discussion linked from issue 1382. Determine the supported way to retain access to active MCP servers and send later notifications, including how stateless servers should be handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100