Alternative to `RunSessionHandler` for accessing MCP servers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- backend-api-design
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.
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)
- Dominant language
- C#
- Stars
- 4.6k
- Forks
- 817
- Avg merge
- 8d 7h
- Merged PRs (30d)
- 3
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from modelcontextprotocol/csharp-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/csharp-sdk#1867 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
modelcontextprotocol/csharp-sdk#1840 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/csharp-sdk#1836 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement needs confirmation
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
modelcontextprotocol/csharp-sdk#678 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement needs confirmation P3 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/csharp-sdk#515 · 6 comments · 3 reactions ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/csharp-sdk
Similar issues
-
WPF: each page's `Title` overwrites the window title, and returning to a page does not restore itOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
agentic-workflows area/Docs partner/agentic-workflows
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jamesmontemagno/tiny-clips#378 · 2 comments ·
Maintainers usually reply within 1 day
-
go 🏃 testing 🧪
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
valkey-io/valkey-glide#7239 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15462 ·
Maintainers usually reply within 1 day