Claude Preview MCP: Add preview_navigate tool to fix unreliable page navigation
Problem
When the preview dev server restarts (via preview_stop + preview_start), the browser tab loses its connection and lands on chrome-error://chromewebdata/. There is no reliable way to navigate the tab back to the dev server URL.
The current workaround is using preview_eval to run window.location.href = 'http://localhost:...' on the chrome-error page, but this is unreliable because:
- JS execution on
chrome-error://is restricted -window.locationassignments sometimes work but often the page context resets between calls - Race conditions - subsequent
preview_evalcalls frequently find the page has reverted tochrome-error://because the navigation had not completed - DOM queries fail silently -
document.querySelectorAll('select')returns results in one call, then returns empty in the next because the page context was lost mid-navigation
This makes the preview workflow fragile. A typical recovery sequence requires 3-5 attempts of preview_eval + preview_screenshot before the page stabilizes.
Proposed Solution
Add a preview_navigate tool that uses the browser's native navigation API (e.g., Playwright's page.goto() or CDP's Page.navigate) rather than injecting JS into the current page context.
preview_navigate(serverId: string, url?: string)
urldefaults to the server's localhost URL if omitted- Uses native browser navigation, not JS eval
- Waits for the page to reach a loaded state before returning
This would complement the existing preview_eval tool, which is great for in-page debugging but not suited for navigation from error states.
Current Workaround
- Avoid
preview_stopwhen possible (rely onpreview_startreusing running servers) - Use
window.location.replace()viapreview_evaland take apreview_screenshotbetween every eval call to force a render wait - Retry navigation multiple times until it sticks
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗