Skip to content

MCP client terminates with vercel ai sdk #21

@AtiqGauri

Description

@AtiqGauri

I used this mcp with vercel ai-sdk

const browserRenderingMcpClient = await experimental_createMCPClient({
			transport: {
				url: "https://***.workers.dev/sse",
				type: "sse",
			},
			name: "run_browser",
			onUncaughtError: (error) => {
				console.log("mcp client error: ", error);
				log.error({ error }, "MCP client error");
			},
		});

I get this error in long running agent flows:

POST /chat 200
mcp client error: TypeError: terminated
at Fetch.onAborted (node:internal/deps/undici/undici:11132:53)
at Fetch.emit (node:events:518:28)
at Fetch.terminate (node:internal/deps/undici/undici:10290:14)
at Object.onError (node:internal/deps/undici/undici:11253:38)
at Request.onError (node:internal/deps/undici/undici:2094:31)
at Object.errorRequest (node:internal/deps/undici/undici:1591:17)
at TLSSocket.<anonymous> (node:internal/deps/undici/undici:6319:16)
at TLSSocket.emit (node:events:530:35)
at node:net:346:12
at TCP.done (node:_tls_wrap:650:7) {
[cause]: BodyTimeoutError: Body Timeout Error
at FastTimer.onParserTimeout [as _onTimeout] (node:internal/deps/undici/undici:6253:32)
at Timeout.onTick [as _onTimeout] (node:internal/deps/undici/undici:2210:17)
at listOnTimeout (node:internal/timers:588:17)
at process.processTimers (node:internal/timers:523:7) {
code: 'UND_ERR_BODY_TIMEOUT'
}
}
MCP client error

Metadata

Metadata

Assignees

No one assigned

    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