browser_tab_select
Enables selection of a specific browser tab by index for precise navigation and control in automated web interactions within the Playwright MCP server.
Instructions
Select a tab by index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | The index of the tab to select |
Implementation Reference
- src/tools/tabs.ts:60-71 (handler)The main handler function for the 'browser_tab_select' tool. It invokes context.selectTab to switch to the specified tab and returns mock code execution details.handle: async (context, params) => { await context.selectTab(params.index); const code = [ `// <internal code to select tab ${params.index}>`, ]; return { code, captureSnapshot, waitForNetwork: false }; },
- src/tools/tabs.ts:50-58 (schema)Schema definition including input validation for the tab index parameter.schema: { name: 'browser_tab_select', title: 'Select a tab', description: 'Select a tab by index', inputSchema: z.object({ index: z.number().describe('The index of the tab to select'), }), type: 'readOnly', },
- src/context.ts:122-125 (helper)Core helper method that implements tab selection by updating the current tab reference and bringing the page to the front using Playwright.async selectTab(index: number) { this._currentTab = this._tabs[index - 1]; await this._currentTab.page.bringToFront(); }
- src/tools/tabs.ts:129-134 (registration)Registration of the browser_tab_select tool (via selectTab factory) in the tabs tools module export.export default (captureSnapshot: boolean) => [ listTabs, newTab(captureSnapshot), selectTab(captureSnapshot), closeTab(captureSnapshot), ];
- src/tools.ts:36-52 (registration)Top-level registration where tabs tools module (including browser_tab_select) is included in the snapshotTools array.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...video, ...wait(true), ];