Skip to content

fix(puppeteer): return isError instead of internal error on navigation failure#4051

Open
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:archive-serversfrom
blackwell-systems:fix/puppeteer-navigate-iserror
Open

fix(puppeteer): return isError instead of internal error on navigation failure#4051
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:archive-serversfrom
blackwell-systems:fix/puppeteer-navigate-iserror

Conversation

@blackwell-systems
Copy link
Copy Markdown

Summary

puppeteer_navigate throws an unhandled CDP Protocol error when given an invalid or empty URL. The error propagates as a JSON-RPC -32603 internal error, which prevents agents from detecting and recovering from the failure.

The fix wraps page.goto() in a try/catch and returns isError: true with the error message, matching the pattern already used by puppeteer_screenshot (which correctly catches missing selectors and returns isError: true).

Reproduction

# Using mcp-assert (https://github.com/blackwell-systems/mcp-assert)
mcp-assert audit --server "npx @modelcontextprotocol/server-puppeteer"

# Result:
#   puppeteer_navigate    CRASH    internal error: Protocol error (Page.navigate): Cannot navigate to invalid URL

Manual reproduction: call puppeteer_navigate with {"url": ""} or {"url": "not-a-url"}.

Expected: { isError: true, content: [{ text: "Navigation failed: ..." }] }
Actual: JSON-RPC -32603 internal error (unhandled exception)

Change

One-line change in src/puppeteer/index.ts: wrap the existing page.goto(args.url) call in a try/catch block that returns a structured isError: true response on failure.

Found with mcp-assert, a testing tool for MCP servers.

…n 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)
blackwell-systems added a commit to blackwell-systems/mcp-assert that referenced this pull request Apr 26, 2026
7 tools discovered, 7 assertions. 1 bug: puppeteer_navigate
crashes with internal error on invalid URLs instead of returning
isError. Fix PR submitted (modelcontextprotocol/servers#4051).
Server #40.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant