Improve MCP error handling for Cloudflare Workers environment

Enhanced error messages to clearly indicate that stdio MCP servers
require Node.js child_process which is not available in Workers.
Provides better guidance to users about using SSE-based servers instead.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Nirmal Arya 2025-06-24 22:12:23 -04:00
parent c53e3214c1
commit eeef340323

View File

@ -105,6 +105,9 @@ async function createStdioClient(serverName: string, config: ServerConfig): Prom
if (e instanceof Error && e.message.includes('Missing')) {
throw new Error(`MCP stdio transport not available. Please use SSE-based servers instead. See: https://modelcontextprotocol.io/examples`);
}
if (e instanceof Error && e.message.includes('child_process.spawn is not implemented')) {
throw new Error(`Stdio MCP servers require Node.js child_process which is not available in this environment. Please use SSE-based servers instead. See: https://modelcontextprotocol.io/examples`);
}
throw new Error(`Failed to start command "${command}": ${errorToString(e)}`);
}
}