Skip to main content
Glama
maderwin

pinchtab-mcp

Press Key

pinchtab_press

Press a keyboard key like Enter or Tab, optionally on a specific element, to trigger actions or navigation.

Instructions

Press a keyboard key (e.g. 'Enter', 'Tab', 'Escape', 'ArrowDown'). Optionally target a specific element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g. 'Enter', 'Tab', 'Escape')
refNoElement ref to focus before pressing the key (e.g. 'e5').

Implementation Reference

  • The handler function for the 'pinchtab_press' tool. It receives { key, ref }, builds a body with kind:'press', and calls pinch('POST', '/action', body). On error it returns a toolError.
      async ({ key, ref }) => {
        try {
          const body: Record<string, unknown> = { key, kind: "press" };
          if (ref) body.ref = ref;
          return toolResult(await pinch("POST", "/action", body));
        } catch (error) {
          return toolError(error);
        }
      },
    );
  • The tool metadata and input schema for 'pinchtab_press'. Defines 'key' (string, required) and 'ref' (string, optional) inputs. Also sets the description and title.
    {
      description:
        "Press a keyboard key (e.g. 'Enter', 'Tab', 'Escape', 'ArrowDown'). Optionally target a specific element.",
      inputSchema: z.object({
        key: z.string().describe("Key to press (e.g. 'Enter', 'Tab', 'Escape')"),
        ref: z
          .string()
          .optional()
          .describe("Element ref to focus before pressing the key (e.g. 'e5')."),
      }),
      title: "Press Key",
    },
  • Registration of the 'pinchtab_press' tool via server.registerTool(...) inside the registerInteractionTools function.
    server.registerTool(
      "pinchtab_press",
      {
        description:
          "Press a keyboard key (e.g. 'Enter', 'Tab', 'Escape', 'ArrowDown'). Optionally target a specific element.",
        inputSchema: z.object({
          key: z.string().describe("Key to press (e.g. 'Enter', 'Tab', 'Escape')"),
          ref: z
            .string()
            .optional()
            .describe("Element ref to focus before pressing the key (e.g. 'e5')."),
        }),
        title: "Press Key",
      },
      async ({ key, ref }) => {
        try {
          const body: Record<string, unknown> = { key, kind: "press" };
          if (ref) body.ref = ref;
          return toolResult(await pinch("POST", "/action", body));
        } catch (error) {
          return toolError(error);
        }
      },
    );
  • The toolResult helper wraps data into an MCP content response. Used by the handler to return success results.
    /** Wrap a tool handler with standardized error handling. */
    export function toolResult(data: unknown): ToolResult {
      return { content: [{ text: toJson(data), type: "text" as const }] };
    }
    
    /** Format an error as an MCP tool error response. */
    export function toolError(error: unknown): ToolResult {
      const message = error instanceof Error ? error.message : String(error);
      return {
        content: [{ text: message, type: "text" as const }],
        isError: true,
      };
    }
  • The pinch() helper sends HTTP requests to the PinchTab backend. The handler calls pinch('POST', '/action', body) to execute the key press action.
    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?

With no annotations, the description carries full burden for behavioral disclosure. It does not explain key press mechanics (e.g., keydown/keyup, whether it works without focus), side effects, or error conditions. The optional targeting is vaguely mentioned without detail on how it works.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences, front-loading the main action. It avoids unnecessary words but could benefit from slightly more structure (e.g., listing key examples in a clearer format).

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 browser automation and lack of output schema or annotations, the description is insufficient. It does not cover important details like modifier key support, element focus requirements, or what happens if the key press fails. The agent may misinterpret the tool's behavior.

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%, with schema descriptions for both 'key' and 'ref' already clear. The description adds only that targeting is optional, which is already implied by the parameter being not required. Baseline 3 is appropriate.

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 clearly states the tool presses a keyboard key, with examples like 'Enter', 'Tab', etc. It mentions optional element targeting, which distinguishes it from sibling tools like pinchtab_type (typing text) and pinchtab_click (mouse 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?

The description provides no explicit guidance on when to use this tool versus alternatives. It lacks context such as when a key press is preferred over typing or clicking, and does not mention prerequisites or exclusions.

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