From f84f873c7046439f815eba7cd93cd9eae1efac3b Mon Sep 17 00:00:00 2001 From: Dayna Blackwell Date: Sun, 26 Apr 2026 06:30:07 -0700 Subject: [PATCH] fix(puppeteer): return isError instead of internal error on navigation failure puppeteer_navigate throws an unhandled Protocol error when given an invalid URL (e.g., empty string, malformed URL). The CDP error propagates as a JSON-RPC -32603 internal error, which prevents agents from detecting and recovering from the failure. Wrap page.goto() in a try/catch and return isError: true with the error message, matching the pattern used by puppeteer_screenshot and other tools in this server. Reproduction: mcp-assert audit --server "npx @modelcontextprotocol/server-puppeteer" # puppeteer_navigate: CRASH (internal error) Found with mcp-assert (https://github.com/blackwell-systems/mcp-assert) --- src/puppeteer/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/puppeteer/index.ts b/src/puppeteer/index.ts index 63007799b8..1b61feefd8 100644 --- a/src/puppeteer/index.ts +++ b/src/puppeteer/index.ts @@ -217,7 +217,17 @@ async function handleToolCall(name: string, args: any): Promise switch (name) { case "puppeteer_navigate": - await page.goto(args.url); + try { + await page.goto(args.url); + } catch (error) { + return { + content: [{ + type: "text", + text: `Navigation failed: ${error instanceof Error ? error.message : String(error)}`, + }], + isError: true, + }; + } return { content: [{ type: "text",