Add browser_new_page tool for opening URLs in new tabs #136
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.
Add browser_new_page Tool
Overview
This PR adds the
browser_new_pagetool to Browser MCP, enabling AI applications to open URLs in new browser tabs. This feature enhances multi-tab workflows and allows AI assistants to manage multiple browser contexts simultaneously.Note: This PR includes the MCP server changes. The Chrome extension will need corresponding updates (handler for
browser_new_pagemessage), which should be coordinated with the maintainers as the extension source is not publicly available.Changes Made
1. Added
newPageTool ImplementationFile:
src/tools/common.ts(lines 123-148)NewPageSchemaZod validator for URL parameternewPagetool factory following existing patternbrowser_new_pageWebSocket message to Chrome extensionsnapshot=true)2. Registered Tool in Server
File:
src/index.ts(line 31)common.newPage(true)tosnapshotToolsarraynavigatefor logical grouping of navigation tools3. Updated Documentation
File:
CLAUDE.mdnewPageto the list of common toolsbrowser_new_pagefeature implementation detailsFile:
extension-changes.patch(new)Implementation Details
Tool Schema
Tool Factory
Message Flow
Backward Compatibility
This change is backward compatible:
browser_new_pagemessage, WebSocket call will fail gracefullynavigate,goBack,goForwardChrome Extension Requirement
Important: This MCP server change requires corresponding Chrome extension support to function.
The extension will need to:
browser_new_pageWebSocket messagechrome.tabs.create({url})to open new tabsExtension Implementation Note: The Chrome extension source is not publicly available. The required changes have been tested in a modified version of the extension and are documented in
extension-changes.patch. The patch includes:browser_new_pagetool (pq2variable)browser_new_page: async({url:t}) => { await chrome.tabs.create({url:t}) }Testing
Manual Testing (with modified extension)
browser_new_pagehandlerbrowser_new_pagewith a URLExpected Behavior
Success case:
Error case (extension not modified):
Files Changed
src/tools/common.ts- Added newPage function (+27 lines, +1 import)src/index.ts- Registered tool (+1 line)CLAUDE.md- Updated documentationextension-changes.patch- Chrome extension modification guide (new file)Dependencies
ToolFactorypatternMigration Notes
For Users
Once merged, users will need:
npx @browsermcp/mcp@latest)Until the extension changes are applied, users can use a modified extension or the feature will gracefully fail.
For Developers
The implementation mirrors the pattern used by:
navigate(snapshot)- URL navigation with optional snapshotgoBack(snapshot)/goForward(snapshot)- Simple actions with optional snapshotWhen adding similar tools, follow this same pattern.
Questions & Answers
Q: Why not use the existing navigate tool?
A:
navigatechanges the current tab.browser_new_pageopens a new tab, allowing multi-tab workflows.Q: What if the extension doesn't support browser_new_page?
A: The WebSocket message will timeout or error. The tool degrades gracefully.
Q: Should this use NewPageTool from @repo/types/mcp/tool?
A: Ideally yes, but since this is a new tool, the Zod schema is defined inline. Once merged, it can be moved to the types package in a follow-up PR.
Checklist
Author Notes
This feature has been tested with a modified Chrome extension that includes the corresponding
browser_new_pagehandler. The extension changes are documented inextension-changes.patchfor the maintainers to apply. The modification is minimal and follows the existing pattern for WebSocket message handlers in the extension.