Skip to main content
Glama

close_tab

Automatically close a specific tab in Firefox using the Firefox MCP Server. Simplify browser automation by targeting tabs with their unique ID for efficient control and debugging.

Instructions

Close a specific tab

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdYes

Implementation Reference

  • The main handler function for the 'close_tab' tool. It closes the specified tab's page, removes it from the pages map, clears associated debug buffers, updates the active tab if necessary, and returns a success message.
    async closeTab(args) {
      const { tabId } = args;
      
      if (!this.pages.has(tabId)) {
        throw new Error(`Tab '${tabId}' not found`);
      }
    
      const page = this.pages.get(tabId);
      await page.close();
      this.pages.delete(tabId);
      
      // Clear debug buffers
      this.clearTabDebugBuffers(tabId);
    
      // If this was the active tab, clear active tab
      if (this.activeTabId === tabId) {
        this.activeTabId = this.pages.size > 0 ? Array.from(this.pages.keys())[0] : null;
      }
    
      return {
        content: [{
          type: 'text',
          text: `Tab '${tabId}' closed and debug buffers cleared.${this.activeTabId ? ` Active tab is now '${this.activeTabId}'` : ''}`
        }]
      };
    }
  • Dispatch/registration in the tool request handler switch statement, which calls the closeTab method when 'close_tab' is invoked.
    case 'close_tab':
      return await this.closeTab(args);
  • Tool schema definition in the listTools response, specifying the name, description, and input schema requiring 'tabId'.
    name: 'close_tab',
    description: 'Close a specific tab',
    inputSchema: {
      type: 'object',
      properties: { tabId: { type: 'string' } },
      required: ['tabId']
    }
  • Helper method called by closeTab to clear debug buffers associated with the closed tab.
    clearTabDebugBuffers(tabId) {
      this.consoleLogs.delete(tabId);
      this.jsErrors.delete(tabId);
      this.networkActivity.delete(tabId);
      this.wsMessages.delete(tabId);
      this.performanceMetrics.delete(tabId);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Close a specific tab' implies a destructive action, but it doesn't specify whether this requires the tab to be active, if it prompts for confirmation, what happens to unsaved data, or if there are side effects like browser closure. This leaves critical behavioral traits undocumented.

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 with just four words, front-loading the core action without any fluff. Every word earns its place by directly conveying the tool's purpose, making it easy to scan and understand quickly.

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 complexity of a destructive tab-closing operation, no annotations, no output schema, and minimal parameter semantics, the description is incomplete. It doesn't address prerequisites, error conditions, or what happens post-execution (e.g., does it return a status?), leaving significant gaps for safe and effective use.

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

Parameters2/5

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

The input schema has 1 parameter with 0% description coverage, and the tool description doesn't add any semantic information about 'tabId'. It doesn't explain what a tabId is, how to obtain it (e.g., from 'list_tabs'), or its format (e.g., numeric vs. string). This fails to compensate for the schema's lack of documentation.

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 'Close a specific tab' clearly states the action (close) and resource (tab), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'close_browser' or 'set_active_tab', which could involve similar tab operations but with different scopes or intents.

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?

The description provides no guidance on when to use this tool versus alternatives. For example, it doesn't clarify if this is for closing individual tabs while keeping the browser open (vs. 'close_browser'), or how it relates to 'set_active_tab' for tab management. Without such context, users must infer usage from the tool name 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

Related 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/JediLuke/firefox-mcp-server'

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