browser_tab_select
Select a specific browser tab by its index to automate web interactions using the Playwright MCP server for structured accessibility snapshots.
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:50-53 (handler)The handler function for the 'browser_tab_select' tool. It selects the tab at the specified index using the context and includes a snapshot in the response.handle: async (context, params, response) => { await context.selectTab(params.index); response.setIncludeSnapshot(); },
- src/tools/tabs.ts:40-48 (schema)The schema definition for the 'browser_tab_select' tool, specifying the input schema requiring a tab index and marking it as readOnly.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/tools/tabs.ts:37-54 (registration)The full tool definition for 'browser_tab_select' using defineTool, which includes schema, handler, and capability. This tool object is exported and registered in the tools array.const selectTab = defineTool({ capability: 'core-tabs', 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', }, handle: async (context, params, response) => { await context.selectTab(params.index); response.setIncludeSnapshot(); }, });
- src/tools/tabs.ts:96-101 (registration)Export of the tabs tools array, including the selectTab tool, which is imported and spread into the allTools collection in src/tools.ts.export default [ listTabs, newTab, selectTab, closeTab, ];
- src/tools.ts:36-52 (registration)Aggregation of all tools, including those from tabs.ts (which contains browser_tab_select), into allTools array for higher-level registration.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];