I'm working on a tool using ModelContextProtocol in C# (.NET 8), and I'm hitting a frustrating issue when trying to run my MCP server from JetBrains Rider.
Here's the setup:
My Program.cs uses WithStdioServerTransport():
builder.Services.AddMcpServer().WithStdioServerTransport().WithToolsFromAssembly();
I can run the project just fine from Visual Studio Code using:
{
"servers": {
"TestMcp": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"/Path/To/My/Project/Project.csproj"
]
}
}
}
and MCP connects in VSCode without issues.
But when I try to run it from Rider, either:
- via a regular Run Configuration
- or via the MCP tool integration (using
.mcp.jsonor JSON config)
I get this error:
MCP error -1: Connection closed
Logging shows that the app does start, and even prints:
Application started...
So stdin/stdout are technically there — but MCP just immediately disconnects when launched from Rider.
Same thing happens if I Dockerize the app and run it via Rider with docker run -i.
What I've tried:
- Switching to WithStreamServerTransport(
Console.OpenStandardInput(),Console.OpenStandardOutput()) – same issue - Manually flushing the streams with
Console.Out.Flush()– still no luck - Setting "type": "stdio" in
.mcp.json– doesn't seem to matter in Rider
Running the same setup from VS Code and Claude Desktop – works perfectly
My Question:
Is this a known issue with Rider and StdioServerTransport in MCP?