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,
    ];
Behavior4/5

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

Annotations provide readOnlyHint=false, destructiveHint=true, and openWorldHint=true, indicating this is a destructive, non-read-only operation with open-world behavior. The description doesn't contradict these but adds minimal context beyond the obvious 'close' action. It doesn't elaborate on effects like tab removal or potential browser state changes, but annotations cover key safety aspects.

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?

Extremely concise with 'Close a tab'—a single, front-loaded sentence that directly states the purpose without any fluff. Every word earns its place, making it easy for an agent to parse quickly.

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 simplicity (one optional parameter) and rich annotations (destructiveHint, openWorldHint), the description is minimally adequate. However, it lacks details on output (no schema provided) and doesn't explain behavioral nuances like what happens after closing (e.g., focus shift), leaving some gaps for the agent.

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. The description adds no parameter information beyond what's in the schema, so it meets the baseline of 3 for high 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' clearly states the action (close) and resource (tab), but it's vague about scope and doesn't distinguish from sibling tools like browser_close (which likely closes the entire browser). It doesn't specify whether it closes the current tab or a specific one, though the schema clarifies this.

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 like browser_close or browser_tab_select. The description lacks context about prerequisites (e.g., needing an open tab) or exclusions, leaving the agent to infer usage from the schema and annotations alone.

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

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