Skip to content

SSE Timeout Error After 5 Minutes Using Cursor #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shaykeren opened this issue Apr 23, 2025 · 3 comments
Closed

SSE Timeout Error After 5 Minutes Using Cursor #344

shaykeren opened this issue Apr 23, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@shaykeren
Copy link

Describe the bug
After running the AspNetCoreSseServer sample with Cursor, I encounter the following error after 5 minutes of idle time:
SSE error: TypeError: terminated: Body Timeout Error

To Reproduce
Steps to reproduce the behavior:

  1. Run the sample SSE server:
    cd samples/AspNetCoreSseServer && dotnet run --configuration Debug
  2. Register the server in MCP config:
    { "mcpServers": { "sse-test-5": { "url": "http://localhost:3001/sse" } } }
  3. Observe that it connects successfully and appears online in Cursor
  4. Wait for 5 minutes (no interaction)
  5. Observe the error:
    SSE error: TypeError: terminated: Body Timeout Error

Expected behavior
The SSE connection should remain open indefinitely (or at least longer than 5 minutes) if idle, without triggering a timeout or client termination error.

Logs
SSE Server Logs:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:3001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /Users/shaykeren/work/csharp-sdk/samples/AspNetCoreSseServer
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0) method 'initialize' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'initialize' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0) method 'initialize' request handler called.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0) method 'initialize' request handler called.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0) method 'initialize' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'initialize' request handler completed.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'initialize' request handler completed.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'initialize' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[570385771]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) method 'tools/list' request handler completed.
info: ModelContextProtocol.Server.McpServer[2103773711]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) message processing canceled.
info: ModelContextProtocol.Server.McpServer[2081236114]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shutting down.
info: ModelContextProtocol.Server.McpServer[613617602]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shut down.
info: ModelContextProtocol.Server.McpServer[2103773711]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) message processing canceled.
info: ModelContextProtocol.Server.McpServer[2081236114]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shutting down.
info: ModelContextProtocol.Server.McpServer[613617602]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shut down.
info: ModelContextProtocol.Server.McpServer[2103773711]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) message processing canceled.
info: ModelContextProtocol.Server.McpServer[2081236114]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shutting down.
info: ModelContextProtocol.Server.McpServer[613617602]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shut down.
info: ModelContextProtocol.Server.McpServer[2103773711]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) message processing canceled.
info: ModelContextProtocol.Server.McpServer[2081236114]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shutting down.
info: ModelContextProtocol.Server.McpServer[613617602]
Server (AspNetCoreSseServer 1.0.0.0), Client (cursor-vscode 1.0.0) shut down.

Cursor MCP Output:
2025-04-23 08:21:43.090 [info] test: Reusing existing sse client
2025-04-23 08:21:43.090 [info] test: Connected to sse server, fetching offerings
2025-04-23 08:21:43.094 [info] listOfferings: Found 2 tools
2025-04-23 08:21:43.094 [info] test: Found 2 tools, 0 resources, and 0 resource templates
2025-04-23 08:21:43.095 [info] -mcp: Client closed for command
2025-04-23 08:21:43.095 [error] -mcp: Error in MCP: Client closed
2025-04-23 08:21:43.096 [info] test: Handling CreateClient action
2025-04-23 08:21:43.096 [info] test: getOrCreateClient for sse server. process.platform: darwin isElectron: true
2025-04-23 08:21:43.096 [info] test: Reusing existing sse client
2025-04-23 08:21:43.097 [info] -mcp: Handling ListOfferings action
2025-04-23 08:21:43.097 [error] -mcp: No server info found
2025-04-23 08:21:43.097 [info] test: Handling ListOfferings action
2025-04-23 08:21:43.097 [info] test: Listing offerings
2025-04-23 08:21:43.097 [info] test: getOrCreateClient for sse server. process.platform: darwin isElectron: true
2025-04-23 08:21:43.097 [info] test: Reusing existing sse client
2025-04-23 08:21:43.097 [info] test: Connected to sse server, fetching offerings
2025-04-23 08:21:43.101 [info] listOfferings: Found 2 tools
2025-04-23 08:21:43.101 [info] test: Found 2 tools, 0 resources, and 0 resource templates
2025-04-23 08:21:43.152 [info] -mcp: Client closed for command
2025-04-23 08:21:43.152 [error] -mcp: Error in MCP: Client closed
2025-04-23 08:21:43.170 [info] -mcp: Client closed for command
2025-04-23 08:21:43.170 [error] -mcp: Error in MCP: Client closed
2025-04-23 08:26:45.289 [error] test: Client error for command SSE error: TypeError: terminated: Body Timeout Error
2025-04-23 08:26:45.290 [error] test: Error in MCP: SSE error: TypeError: terminated: Body Timeout Error

Additional context
Add any other context about the problem here.

@shaykeren shaykeren added the bug Something isn't working label Apr 23, 2025
@markharrison
Copy link

I have the same issue with VS Code / GH Copilot . My MCP Server was written using the C#SDK and is running as a Docker container. Timeout error after 5 minutes.

Image

@stephentoub
Copy link
Contributor

cc: @halter73

@halter73
Copy link
Contributor

halter73 commented May 9, 2025

If you haven't already, I recommend updating your ModelContextProtocol.AspNetCore package to 0.1.0-preview.12. In that release, I increased the default HttpServerTransportOptions.IdleTimeout from 5 minutes to 2 hours. You can use that option to make the timeout even longer. Timeout.Infinite is also now supported, but it's not a silver bullet since there's also a MaxIdleSessionCount which applies to any idle session even before the timeout to avoid potentially running out of memory. Still, this should be perfectly fine for local scenarios where you control the only client, Cursor.

The new stateless Streamable HTTP support added by #392 gets rid of the need for an IdleTimeout entirely and can be used more reliably for remote connections since it does not rely on storing per-session state in server memory.

@halter73 halter73 closed this as completed May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants