Skip to main content
Glama

browser_tabs

Destructive

Manage browser tabs in Playwright MCP by listing, creating, closing, or selecting tabs for web automation tasks.

Instructions

List, create, close, or select a browser tab.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesOperation to perform
indexNoTab index, used for close/select. If omitted for close, current tab is closed.

Implementation Reference

  • Implementation of the 'browser_tab_list' tool handler, which lists all open browser tabs.
    const listTabs: Tool = {
      capability: 'tabs',
      schema: {
        name: 'browser_tab_list',
        description: 'List browser tabs',
        inputSchema: zodToJsonSchema(z.object({})),
      },
      handle: async context => {
        return {
          content: [{
            type: 'text',
            text: await context.listTabs(),
          }],
        };
      },
    };
  • Implementation of the 'browser_tab_select' tool handler, which selects a browser tab by index.
    const selectTabSchema = z.object({
      index: z.number().describe('The index of the tab to select'),
    });
    
    const selectTab: ToolFactory = captureSnapshot => ({
      capability: 'tabs',
      schema: {
        name: 'browser_tab_select',
        description: 'Select a tab by index',
        inputSchema: zodToJsonSchema(selectTabSchema),
      },
      handle: async (context, params) => {
        const validatedParams = selectTabSchema.parse(params);
        await context.selectTab(validatedParams.index);
        const currentTab = await context.ensureTab();
        return await currentTab.run(async () => {
          const code = [
            `// <internal code to select tab ${validatedParams.index}>`,
          ];
          return { code };
        }, { captureSnapshot });
      },
    });
  • Implementation of the 'browser_tab_new' tool handler, which opens a new browser tab.
    const newTabSchema = z.object({
      url: z.string().optional().describe('The URL to navigate to in the new tab. If not provided, the new tab will be blank.'),
    });
    
    const newTab: Tool = {
      capability: 'tabs',
      schema: {
        name: 'browser_tab_new',
        description: 'Open a new tab',
        inputSchema: zodToJsonSchema(newTabSchema),
      },
      handle: async (context, params) => {
        const validatedParams = newTabSchema.parse(params);
        await context.newTab();
        if (validatedParams.url)
          await context.currentTab().navigate(validatedParams.url);
        return await context.currentTab().run(async () => {
          const code = [
            `// <internal code to open a new tab>`,
          ];
          return { code };
        }, { captureSnapshot: true });
      },
    };
  • Implementation of the 'browser_tab_close' tool handler, which closes a browser tab.
    const closeTabSchema = z.object({
      index: z.number().optional().describe('The index of the tab to close. Closes current tab if not provided.'),
    });
    
    const closeTab: ToolFactory = captureSnapshot => ({
      capability: 'tabs',
      schema: {
        name: 'browser_tab_close',
        description: 'Close a tab',
        inputSchema: zodToJsonSchema(closeTabSchema),
      },
      handle: async (context, params) => {
        const validatedParams = closeTabSchema.parse(params);
        await context.closeTab(validatedParams.index);
        const currentTab = context.currentTab();
        if (currentTab) {
          return await currentTab.run(async () => {
            const code = [
              `// <internal code to close tab ${validatedParams.index}>`,
            ];
            return { code };
          }, { captureSnapshot });
        }
        return {
          content: [{
            type: 'text',
            text: await context.listTabs(),
          }],
        };
      },
    });
  • src/index.ts:37-47 (registration)
    Registration of the browser tabs tools (from tabs(true)) into the snapshotTools array used by the MCP server.
    const snapshotTools: Tool[] = [
      ...common(true),
      ...console,
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...pdf,
      ...snapshot,
      ...tabs(true),
    ];
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide key behavioral traits: readOnlyHint=false (mutation possible), openWorldHint=true (unpredictable environment), and destructiveHint=true (can cause data loss). The description adds context by specifying actions like 'close' that align with destructive behavior, but doesn't elaborate on risks, permissions, or rate limits beyond what annotations cover.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (one sentence) and front-loaded with all key actions. Every word earns its place, with no redundant or verbose phrasing. It efficiently communicates the tool's scope without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (multiple actions, destructive potential) and lack of output schema, the description is minimally adequate. Annotations cover safety and environment traits, but the description doesn't explain return values, error conditions, or interaction effects, leaving gaps for an agent to infer behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters (action and index). The description mentions actions like 'list' and 'close' that map to the action enum, but adds no syntax, format, or semantic details beyond what the schema provides. Baseline 3 is appropriate given high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs (list, create, close, select) and resource (browser tab). It distinguishes from siblings like browser_close (which closes the browser, not tabs) and browser_navigate (which navigates within a tab), though it doesn't explicitly mention these distinctions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives is provided. The description lists actions but doesn't indicate when to choose 'list' versus 'new', or when to use this tool over sibling tools like browser_close for closing the entire browser. No prerequisites or exclusions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/markbustamante77/mcp'

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