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
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | Yes |
Implementation Reference
- index-multi-debug.js:981-1006 (handler)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}'` : ''}` }] }; }
- index-multi-debug.js:403-404 (registration)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);
- index-multi-debug.js:78-84 (schema)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'] }
- index-multi-debug.js:477-483 (helper)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); }