Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

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

Implementation Reference

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

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/cloudflare/playwright-mcp'

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