-
Notifications
You must be signed in to change notification settings - Fork 516
Description
Describe the bug
We have an MCP server using the C# SDK and the latest iteration of the code with the latest spec changes.
Utilizing stateless mode with this MCP server does not work as intended.
- When using a single instance, the MCP server works as intended.
- When using multiple instances, the MCP server instances are backed by a L4 load balancer, no session affinity, the connection works intermittently, giving 500 response codes and connection errors most of the time, due to a subsequent request (tools/list) landing on a different machine than the first request (initialize).
To Reproduce
Steps to reproduce the behavior:
- Create MCP server
- Scale MCP server to more than one instance
- Try to connect to the server from a client
Expected behavior
The MCP server correctly handles stateless behavior by routing requests without session affinity and successfully connecting to the MCP server 100% of the time regardless of which server was hit.
Logs
2025-08-06 12:40:06.005 [info] Starting server MCPServer
2025-08-06 12:40:06.005 [info] Connection state: Starting
2025-08-06 12:40:06.009 [info] Starting server from LocalProcess extension host
2025-08-06 12:40:06.009 [info] Connection state: Running
2025-08-06 12:40:06.009 [debug] [editor -> server] {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"roots":{"listChanged":true},"sampling":{},"elicitation":{}},"clientInfo":{"name":"Visual Studio Code","version":"1.102.1"}}}
2025-08-06 12:40:07.608 [debug] [server -> editor] {"result":{"protocolVersion":"2024-11-05","capabilities":{"logging":{},"tools":{"listChanged":true}},"serverInfo":{"name":"MCPServer","version":"1.0.0"}},"id":1,"jsonrpc":"2.0"}
2025-08-06 12:40:07.608 [debug] [editor -> server] {"method":"notifications/initialized","jsonrpc":"2.0"}
2025-08-06 12:40:07.608 [debug] [editor -> server] {"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
2025-08-06 12:40:07.950 [info] Connection state: Error 500 status sending message to https://your_mcp_server.com/: