Skip to content

MCP plugin on Cloudflare workers is not working #14716

@promentol

Description

@promentol

Describe the Bug

MCP plugin is not working on Cloudflare workers

After debugging locally the issue is following

[wrangler:info] POST /api/mcp 500 Internal Server Error (359ms)
✘ [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/ 

Theoretically, there is some action or unresolved promise, which needs to be wrapped inside ctx.waitUntil or just awaited

Link to the code that reproduces this issue

https://github.com/promentol/payload-mcp-cloudflare-demo

Reproduction Steps

Start Cloudflare worker template
Integrate MCP servier
MCP server works fine with next dev
After building and running with wrangler dev or when deploying to workers, it throws error when connecting to MCP server

Which area(s) are affected? (Select all that apply)

plugin: other

Environment Info

Node.js v24.1.0

Binaries:
  Node: 24.1.0
  npm: 11.3.0
  Yarn: N/A
  pnpm: 9.11.0
Relevant Packages:
  payload: 3.64.0
  next: 15.4.7
  @payloadcms/db-d1-sqlite: 3.64.0
  @payloadcms/drizzle: 3.64.0
  @payloadcms/graphql: 3.64.0
  @payloadcms/next/utilities: 3.64.0
  @payloadcms/plugin-cloud-storage: 3.64.0
  @payloadcms/plugin-mcp: 3.64.0
  @payloadcms/richtext-lexical: 3.64.0
  @payloadcms/storage-r2: 3.64.0
  @payloadcms/translations: 3.64.0
  @payloadcms/ui/shared: 3.64.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:54 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12

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