Skip to main content
Glama

browser_tab_close

Destructive

Close a browser tab by index or the current tab to manage tab clutter and improve browsing efficiency during web automation tasks.

Instructions

Close a tab

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexNoThe index of the tab to close. Closes current tab if not provided.

Implementation Reference

  • The handler function for browser_tab_close tool that closes the tab using context.closeTab and includes a snapshot in the response.
    handle: async (context, params, response) => {
      await context.closeTab(params.index);
      response.setIncludeSnapshot();
    },
  • Input/output schema definition for the browser_tab_close tool.
    schema: {
      name: 'browser_tab_close',
      title: 'Close a tab',
      description: 'Close a tab',
      inputSchema: z.object({
        index: z.number().optional().describe('The index of the tab to close. Closes current tab if not provided.'),
      }),
      type: 'destructive',
    },
  • Supporting utility method on Context class that performs the actual tab closing using Playwright's page.close().
    async closeTab(index: number | undefined): Promise<string> {
      const tab = index === undefined ? this._currentTab : this._tabs[index];
      if (!tab)
        throw new Error(`Tab ${index} not found`);
      const url = tab.page.url();
      await tab.page.close();
      return url;
    }
  • Where tools including browser_tab_close are registered in the MCP ServerBackend via filteredTools(config).
    constructor(config: FullConfig, factories: FactoryList) {
      this._config = config;
      this._browserContextFactory = factories[0];
      this._tools = filteredTools(config);
      if (factories.length > 1)
        this._tools.push(this._defineContextSwitchTool(factories));
  • src/tools.ts:36-52 (registration)
    Collection of all tools, spreading the tabs tools which includes browser_tab_close.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior3/5

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

Annotations provide key behavioral hints: destructiveHint=true (indicating data loss) and openWorldHint=true (suggesting external effects). The description adds no behavioral context beyond 'Close a tab', such as what happens to unsaved data or if confirmation is needed. It doesn't contradict annotations, but adds minimal value given the annotations cover safety and scope.

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 ('Close a tab') with zero wasted words, making it front-loaded and easy to parse. It efficiently conveys the core action without unnecessary detail, though this brevity contributes to gaps in other dimensions.

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

Completeness2/5

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

Given the tool's destructive nature (per annotations) and lack of output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral nuances like what happens after closing (e.g., focus shift). For a destructive tool with no output schema, more context is needed to guide safe usage.

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 the parameter 'index' fully documented in the schema (closes current tab if not provided). The description adds no parameter semantics beyond what the schema provides, so it meets the baseline of 3 for high schema coverage without extra value.

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

Purpose3/5

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

The description 'Close a tab' states the action (close) and resource (tab), but it's vague about scope and doesn't differentiate from sibling tools like 'browser_close' (which likely closes the entire browser). It doesn't specify whether this closes tabs in a browser context or another environment, leaving ambiguity.

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 is provided on when to use this tool versus alternatives. It doesn't mention siblings like 'browser_tab_list' (to list tabs before closing) or 'browser_tab_select' (to select a tab first), nor does it specify prerequisites such as needing an open browser or tab. Usage context is implied but not explicit.

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