Skip to main content
Glama

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
NameRequiredDescriptionDefault
indexYesThe index of the tab to select

Implementation Reference

  • 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 }; },
  • 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', },
  • 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(); }
  • 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), ];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lewisvoncken/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server