Skip to main content
Glama

pilot_tab_close

Close a browser tab by its ID, or the current tab if no ID is given. Use to remove popups or unwanted tabs.

Instructions

Close a browser tab by its ID, or close the currently active tab if no ID is specified. Use when the user wants to close a popup, remove an unwanted tab, or clean up after finishing work in a tab.

Parameters:

  • id: Tab ID to close (omit to close the current active tab). Use pilot_tabs to list tab IDs.

Returns: Confirmation that the tab was closed.

Errors:

  • "No such tab": The provided tab ID does not exist. Run pilot_tabs to see valid IDs.

  • "Cannot close last tab": The last remaining tab cannot be closed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoTab ID to close

Implementation Reference

  • The handler function for the 'pilot_tab_close' tool. Takes an optional tab ID, ensures a browser is available, then closes the tab via extension message or direct browser method.
      server.tool(
        'pilot_tab_close',
        `Close a browser tab by its ID, or close the currently active tab if no ID is specified.
    Use when the user wants to close a popup, remove an unwanted tab, or clean up after finishing work in a tab.
    
    Parameters:
    - id: Tab ID to close (omit to close the current active tab). Use pilot_tabs to list tab IDs.
    
    Returns: Confirmation that the tab was closed.
    
    Errors:
    - "No such tab": The provided tab ID does not exist. Run pilot_tabs to see valid IDs.
    - "Cannot close last tab": The last remaining tab cannot be closed.`,
          { id: z.number().optional().describe('Tab ID to close') },
        async ({ id }) => {
          await bm.ensureBrowser();
          try {
            const ext = bm.getExtension();
            if (ext) {
              await ext.send('close_tab', { tabId: id });
              return { content: [{ type: 'text' as const, text: `Closed tab${id ? ` ${id}` : ''}` }] };
            }
            await bm.closeTab(id);
            return { content: [{ type: 'text' as const, text: `Closed tab${id ? ` ${id}` : ''}` }] };
          } catch (err) {
            return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
          }
        }
      );
  • Input schema for 'pilot_tab_close': an optional numeric 'id' parameter described as 'Tab ID to close'.
    { id: z.number().optional().describe('Tab ID to close') },
  • 'pilot_tab_close' is listed in the STANDARD_TOOLS set, meaning it is available in the 'standard' and 'full' profiles.
      'pilot_tabs', 'pilot_tab_new', 'pilot_tab_close', 'pilot_tab_select',
      // page reading
      'pilot_page_text', 'pilot_page_html',
      // visual
      'pilot_annotated_screenshot',
      // iframe
      'pilot_frames', 'pilot_frame_select', 'pilot_frame_reset',
      // session + config
      'pilot_auth', 'pilot_block', 'pilot_find',
    ]);
    
    const PROFILE_TOOLS: Record<ToolProfile, Set<string> | null> = {
      core: CORE_TOOLS,
      standard: STANDARD_TOOLS,
      full: null, // null = no filter, register everything
    };
    
    function createFilteredServer(server: McpServer, allowed: Set<string>): McpServer {
      const originalTool = server.tool.bind(server);
    
      const filtered = Object.create(server) as McpServer;
      filtered.tool = ((...args: unknown[]) => {
        const name = args[0] as string;
        if (!allowed.has(name)) return;
        return (originalTool as Function).apply(server, args);
      }) as typeof server.tool;
    
      return filtered;
    }
    
    export function registerAllTools(server: McpServer, bm: BrowserManager, profile: ToolProfile = 'full'): void {
      const allowed = PROFILE_TOOLS[profile];
      const effectiveServer = allowed ? createFilteredServer(server, allowed) : server;
    
      registerNavigationTools(effectiveServer, bm);
      registerSnapshotTools(effectiveServer, bm);
      registerInteractionTools(effectiveServer, bm);
      registerPageTools(effectiveServer, bm);
      registerInspectionTools(effectiveServer, bm);
      registerVisualTools(effectiveServer, bm);
      registerTabTools(effectiveServer, bm);
  • The registerTabTools function is imported from './tabs.js' and called in registerAllTools.
    import { registerTabTools } from './tabs.js';
  • registerTabTools is invoked during registration, which triggers the server.tool() call defining the handler.
    registerTabTools(effectiveServer, bm);
Behavior5/5

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

With no annotations, the description fully covers behavioral traits: default close of active tab, confirmation return, and two specific error conditions ('No such tab' and 'Cannot close last tab'). It discloses all key behaviors.

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 concise, with clear sections for purpose, parameters, returns, and errors. Every sentence adds value without redundancy.

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

Completeness5/5

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

Given the tool's simplicity (1 optional parameter, no output schema), the description is complete: includes purpose, usage guidance, parameter behavior, and error handling. No gaps remain.

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

Parameters5/5

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

Schema coverage is 100%, and the description adds meaning beyond the schema: explains that omitting id closes the active tab, and directs to pilot_tabs for valid IDs. This provides actionable guidance.

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

Purpose5/5

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

The description clearly states 'Close a browser tab by its ID, or close the currently active tab if no ID is specified,' providing a specific verb and resource, and distinguishing behavior from sibling tools like pilot_tab_new and pilot_tab_select.

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

Usage Guidelines5/5

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

Explicitly states when to use: 'when the user wants to close a popup, remove an unwanted tab, or clean up after finishing work in a tab.' It also references sibling tool pilot_tabs for listing IDs, providing clear context and alternatives.

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/TacosyHorchata/Pilot'

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