Skip to main content
Glama

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

Implementation Reference

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

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/nzjami/mcpPlaywright'

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