You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stdio dispatch hangs after exactly 2 sequential tools/call requests (PowerShell client, sequential not concurrent)
Body
Summary
Using .AddMcpServer().WithStdioServerTransport().WithTools<...>() from a PowerShell client (System.Diagnostics.Process redirected stdio), exactly two sequential tools/call requests succeed; the third hangs forever in the framework — the third tool's [McpServerTool]-decorated method is never invoked. Hangs on both 1.2.0 and 1.3.0. Calls are strictly sequential (response read before next request sent), not concurrent (so #88 doesn't apply).
Reproducible characterization
Variable
Result
Three identical lightweight tool calls (e.g. one returning a small JSON string)
ModelContextProtocol 1.2.0 and 1.3.0 (both reproduce)
Server: .NET 8 self-contained single-file Windows x64 process
Client: PowerShell 7.x (pwsh) on Windows 11, Process.Start with RedirectStandardInput/Output = true
Server uses WithStdioServerTransport() and registers ~50 tools via WithTools<T>()
Server setup (relevant excerpt)
builder.Services.AddV1ToolSingletons();// registers each Tool class as singletonbuilder.Services.AddMcpServer().WithStdioServerTransport().AddV1Tools();// calls WithTools<T>() ~50 times
call #1 OK elapsed=0.06s
call #2 OK elapsed=0.01s
call #3 HUNG (timed out at 30s)
Server-side trace at hang
The tool method body for call #3 is never invoked (we instrumented [McpServerTool] methods to log on entry — the log line for call #3 never appears). So the framework's stdio reader or tool-router stalls before dispatch.
The server process sits idle at ~0.5 s CPU for many minutes after call #2 completes — so it's blocked on an await, not spinning. 10 threads.
Draft: upstream issue for
modelcontextprotocol/csharp-sdkTo be filed at: https://github.com/modelcontextprotocol/csharp-sdk/issues/new
Title
Stdio dispatch hangs after exactly 2 sequential tools/call requests (PowerShell client, sequential not concurrent)Body
Summary
Using
.AddMcpServer().WithStdioServerTransport().WithTools<...>()from a PowerShell client (System.Diagnostics.Processredirected stdio), exactly two sequentialtools/callrequests succeed; the third hangs forever in the framework — the third tool's[McpServerTool]-decorated method is never invoked. Hangs on both1.2.0and1.3.0. Calls are strictly sequential (response read before next request sent), not concurrent (so #88 doesn't apply).Reproducible characterization
info,info,infovsinfo,heavy,info)ModelContextProtocol1.2.0 → 1.3.0StreamReader.Peek()+Read()vsReadLineAsync().Wait()Environment
ModelContextProtocol1.2.0 and 1.3.0 (both reproduce)pwsh) on Windows 11,Process.StartwithRedirectStandardInput/Output = trueWithStdioServerTransport()and registers ~50 tools viaWithTools<T>()Server setup (relevant excerpt)
Minimal client repro (PowerShell)
Observed output
Server-side trace at hang
The tool method body for call #3 is never invoked (we instrumented
[McpServerTool]methods to log on entry — the log line for call #3 never appears). So the framework's stdio reader or tool-router stalls before dispatch.The server process sits idle at ~0.5 s CPU for many minutes after call #2 completes — so it's blocked on an
await, not spinning. 10 threads.What we ruled out
SemaphoreSlimexhaustion in our codeAsks
notifications/initializedagain, or send a heartbeat)?Happy to provide a fully self-contained minimal-server repro on request.