browser_tab_select
Select a browser tab to bring it into focus. Use this tool to switch between open tabs during browser automation tasks.
Instructions
browser tab select
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/browser_tools.js:909-946 (handler)The handler function that selects a browser tab by index. Validates input, gets the page from the context's page list, calls bringToFront() to switch to it, and returns success with the tab's URL and title.
async function browserTabSelect(index) { try { if (index === undefined || isNaN(index)) { return { success: false, message: 'Tab index is required' }; } const browser = await getBrowser(); const pages = context ? context.pages() : []; if (index < 0 || index >= pages.length) { return { success: false, message: `Invalid tab index: ${index}. Valid range: 0-${pages.length - 1}` }; } page = pages[index]; await page.bringToFront(); return { success: true, message: `Switched to tab ${index}`, index, url: page.url(), title: await page.title() }; } catch (error) { logger.error(`Error selecting tab: ${error.message}`); return { success: false, message: error.message }; } } - src/mcp/server.js:294-294 (registration)Routes the 'browser_tab_select' MCP tool call to the browserTabSelect handler function, passing args.index.
case 'browser_tab_select': data = await browserTools.browserTabSelect(args.index); break; - src/mcp/server.js:130-130 (registration)Registers 'browser_tab_select' in the tools/list response's browserExtras array so it appears as an available MCP tool.
{ n:'browser_network_requests' }, { n:'browser_tab_list' }, { n:'browser_tab_new' }, { n:'browser_tab_select' }, - src/tools/browser_tools.js:91-100 (helper)Helper function used by browserTabSelect (via getBrowser) to retrieve or create the current page context.
async function getPage() { if (!page || page.isClosed()) { const browser = await getBrowser(); if (!context) { context = await browser.newContext(); } page = await context.newPage(); } return page; } - src/tools/browser_tools.js:1149-1149 (registration)Exports browserTabSelect from the module.exports so it can be imported by server.js.
browserTabSelect,