browser_tab_select
Switch to a specific browser tab by its index to manage multiple web pages during automated testing using Cloudflare Playwright MCP.
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 tool handler for 'browser_tab_select' that invokes context.selectTab(index) and returns a mock code execution result.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)Zod schema definition for the 'browser_tab_select' tool input, requiring a numeric index.schema: { name: 'browser_tab_select', title: 'Select a tab', description: 'Select a tab by index', inputSchema: z.object({ index: z.coerce.number().describe('The index of the tab to select'), }), type: 'readOnly', },
- src/context.ts:103-106 (helper)Core implementation of tab selection in the Context class: sets the current tab by index and brings the page to 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)The tabs tools module exports a function returning an array of tools, including the selectTab tool factory invoked with captureSnapshot parameter.export default (captureSnapshot: boolean) => [ listTabs, newTab(captureSnapshot), selectTab(captureSnapshot), closeTab(captureSnapshot), ];
- src/tools.ts:35-50 (registration)Top-level registration of snapshotTools array which includes tabs(true), thereby registering browser_tab_select among other tools.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...wait(true), ];