fix(puppeteer): return isError instead of internal error on navigation failure#4051
Open
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:archive-serversfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
puppeteer_navigatethrows an unhandled CDPProtocol errorwhen given an invalid or empty URL. The error propagates as a JSON-RPC-32603internal error, which prevents agents from detecting and recovering from the failure.The fix wraps
page.goto()in a try/catch and returnsisError: truewith the error message, matching the pattern already used bypuppeteer_screenshot(which correctly catches missing selectors and returnsisError: true).Reproduction
Manual reproduction: call
puppeteer_navigatewith{"url": ""}or{"url": "not-a-url"}.Expected:
{ isError: true, content: [{ text: "Navigation failed: ..." }] }Actual: JSON-RPC
-32603internal error (unhandled exception)Change
One-line change in
src/puppeteer/index.ts: wrap the existingpage.goto(args.url)call in a try/catch block that returns a structuredisError: trueresponse on failure.Found with mcp-assert, a testing tool for MCP servers.