Skip to content

Workers runtime error in examples/mcp-worker-authenticated when restarting cursor #597

@jldec

Description

@jldec

When restarting Cursor after configuring and authenticating the MCP in examples/mcp-worker-authenticated, I see the following error message.

Image

The error is not fatal - subsequent requests will succeed, and the MCP tools keep working.

Steps to reproduce

  • npm run dev in examples/mcp-worker-authenticated
  • add MCP url to Cursor "Tools and MCP" settings:
    {
      "mcpServers": {
        "mcp-auth": {
          "url": "http://localhost:8787/mcp"
        }
      }
    }
  • Click on the "Connect" button in the new MCP to authenticate in browser
  • The 2 tools (hello and whoami) should become available - you can try calling them from the AI agent.
  • Quit and restart Cursor - notice the errors in the console where the MCP is running. Usually I see 2 of these Errors, but sometimes as many as 5.
    ✘ [ERROR] Uncaught Error: The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/

Notes

  • I have only been able to reproduce this with examples/mcp-worker-authenticated running in dev, and configured from Cursor.
  • The issue does not occur e.g. when calling with MCP inspector, or Claude.
  • I can reproduce reliably, but I believe this is timing sensitive. I'm running the latest main branch of this repo.
  • When I tried to use a remote KV binding, the issue becomes harder to reproduce, but still happens intermittently.
  • When I added logging to the example worker by parsing the request body early, and passing it to the handler, the issue stopped happening.
  • I also cannot reproduce this when the worker is deployed to Cloudflare.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions