You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the streamText() function from the vercel/ai package on a Cloudflare MCP server, I get this error:
Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope.
This happens because Cloudflare Workers don't allow async operations like fetch() outside of request handlers.
The MCP server configured for the agent is:
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio"
.
.
.
transport: new Experimental_StdioMCPTransport({
command: "npx",
args: ["mcp-remote", "https://autorag.mcp.cloudflare.com/sse"]
})