Skip to main content
Glama
maderwin

pinchtab-mcp

Close Tab

pinchtab_close_tab

Close the active browser tab or a specific tab by providing its ID.

Instructions

Close the current tab or a specific tab by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdNoTab ID to close. If omitted, closes the current tab.

Implementation Reference

  • Handler function for pinchtab_close_tab. Accepts optional tabId, sends POST /tab with {action:'close'} and optionally tabId to the PinchTab HTTP API via pinch().
    async ({ tabId }) => {
      try {
        const body: Record<string, unknown> = { action: "close" };
        if (tabId) body.tabId = tabId;
        return toolResult(await pinch("POST", "/tab", body));
      } catch (error) {
        return toolError(error);
      }
    },
  • Input schema for pinchtab_close_tab. Defines optional tabId (string) parameter for closing a specific tab.
    {
      description: "Close the current tab or a specific tab by its ID.",
      inputSchema: z.object({
        tabId: z
          .string()
          .optional()
          .describe("Tab ID to close. If omitted, closes the current tab."),
      }),
      title: "Close Tab",
  • Registration of 'pinchtab_close_tab' tool on the MCP server via server.registerTool() inside registerInstanceTools().
    server.registerTool(
      "pinchtab_close_tab",
      {
        description: "Close the current tab or a specific tab by its ID.",
        inputSchema: z.object({
          tabId: z
            .string()
            .optional()
            .describe("Tab ID to close. If omitted, closes the current tab."),
        }),
        title: "Close Tab",
      },
      async ({ tabId }) => {
        try {
          const body: Record<string, unknown> = { action: "close" };
          if (tabId) body.tabId = tabId;
          return toolResult(await pinch("POST", "/tab", body));
        } catch (error) {
          return toolError(error);
        }
      },
    );
  • registerAllTools() calls registerInstanceTools(server), which registers pinchtab_close_tab along with other instance tools.
    export function registerAllTools(server: McpServer) {
      registerInstanceTools(server);
      registerNavigationTools(server);
      registerInteractionTools(server);
      registerContentTools(server);
    }
  • The pinch() helper function sends HTTP requests (POST /tab with body) to the PinchTab local API, used by the handler.
    export async function pinch(
      method: string,
      path: string,
      body?: Record<string, unknown>,
    ): Promise<unknown> {
      if (!(await isPinchtabRunning())) {
        await ensurePinchtabRunning();
      }
    
      const headers: Record<string, string> = {
        "Content-Type": "application/json",
      };
      if (PINCHTAB_TOKEN) {
        headers["Authorization"] = `Bearer ${PINCHTAB_TOKEN}`;
      }
    
      const url = `${PINCHTAB_URL}${path}`;
    
      let res: Response;
      try {
        res = await fetch(url, {
          body: body ? JSON.stringify(body) : undefined,
          headers,
          method,
          signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
        });
      } catch (error) {
        if (error instanceof DOMException && error.name === "TimeoutError") {
          throw new Error(`PinchTab ${method} ${path} timed out after ${REQUEST_TIMEOUT_MS / 1000}s`);
        }
        throw error;
      }
    
      if (!res.ok) {
        const text = await res.text();
        throw new Error(`PinchTab ${method} ${path} → ${res.status}: ${text}`);
      }
    
      const contentType = (res.headers.get("content-type") ?? "").split(";")[0].toLowerCase().trim();
      if (contentType === "application/json") {
        return res.json();
      }
      return res.text();
    }
Behavior2/5

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

No annotations are present, so the description bears full responsibility for disclosing behavioral traits. It only says 'close,' which implies a destructive action, but fails to mention that it cannot be undone, what happens to tab state, or error handling for invalid tab IDs. This lack of detail leaves the agent unaware of side effects.

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?

Single sentence that is concise, clear, and front-loaded with the action. No wasted words or redundant information. It efficiently communicates the core functionality.

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

Completeness4/5

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

Given the low complexity (one optional parameter, no output schema), the description covers the essential behavior: two usage modes. However, it lacks context about return values or success/failure feedback, which would be helpful for error handling. Still, it is sufficient for a simple close operation.

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 coverage is 100%, so baseline is 3. The description adds value by explaining the default behavior when tabId is omitted ('closes the current tab'). However, it does not elaborate on format constraints or validation beyond schema, so it meets but does not exceed the baseline meaningfully.

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 the tool's function: closing a tab, either the current one or a specific one by ID. The verb 'close' and resource 'tab' are explicit, and the two usage modes are distinguished. It differentiates well from sibling tools like navigate or click.

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 (e.g., when to close vs. navigate away). There is no mention of prerequisites, such as requiring the tab to exist, or when not to use it. The description only states what it does, not when to apply it.

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/maderwin/pinchtab-mcp'

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