Skip to main content
Glama

type_text

Destructive

Type text at cursor position using clipboard paste with Unicode support. Temporarily replaces clipboard contents; for secure fields, use clipboard_write + cmd+v alternative.

Instructions

Type text at the current cursor position using clipboard paste. Supports full Unicode including CJK characters and emoji. Temporarily replaces clipboard contents. Non-text clipboard content (images, files) will be lost permanently. If secure input is active (e.g. password fields), returns a note suggesting clipboard_write + press_key("cmd+v") as an alternative.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to type. Supports full Unicode including CJK and emoji.

Implementation Reference

  • The handler function for the 'type_text' tool, which performs a copy-to-clipboard and paste operation to simulate typing.
    async function handleTypeText(
      args: Record<string, unknown>,
    ): Promise<CallToolResult> {
      const parsed = TypeTextInputSchema.parse(args);
    
      // Save current clipboard contents (best-effort)
      let oldClipboard = "";
      try {
        oldClipboard = await clipboardRead();
      } catch {
        // Clipboard may be empty or contain non-text data
      }
    
      // Write target text to clipboard
      await clipboardWrite(parsed.text);
    
      // Paste via AppleScript Cmd+V
      await execFileAsync(
        "osascript",
        [
          "-e",
          `tell application "System Events" to key code ${KEY_CODES.v} using command down`,
        ],
        { timeout: APPLESCRIPT_TIMEOUT_MS },
      );
    
      // Brief delay for paste to settle before restoring clipboard
      await new Promise((resolve) => setTimeout(resolve, PASTE_SETTLE_MS));
    
      // Restore previous clipboard contents (best-effort)
      try {
        await clipboardWrite(oldClipboard);
      } catch {
        // Best-effort restore
      }
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify({
              success: true,
              typed_length: parsed.text.length,
            }),
          },
        ],
      };
    }
  • Zod input schema definition for the 'type_text' tool.
    const TypeTextInputSchema = z.object({
      text: z
        .string()
        .min(1)
        .max(100_000)
        .describe("Text to type. Supports full Unicode including CJK and emoji."),
    });
  • Registration of the 'type_text' tool definition.
    {
      name: "type_text",
      description:
        'Type text at the current cursor position using clipboard paste. Supports full Unicode including CJK characters and emoji. Temporarily replaces clipboard contents. Non-text clipboard content (images, files) will be lost permanently. If secure input is active (e.g. password fields), returns a note suggesting clipboard_write + press_key("cmd+v") as an alternative.',
      inputSchema: zodToToolInputSchema(TypeTextInputSchema),
      annotations: {
        readOnlyHint: false,
        destructiveHint: true,
      },
    },
Behavior5/5

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

The description adds significant behavioral context beyond annotations: it discloses clipboard replacement ('Temporarily replaces clipboard contents'), data loss risk ('Non-text clipboard content... will be lost permanently'), and fallback behavior for secure fields. Annotations only indicate destructiveHint=true and readOnlyHint=false, so this extra detail is valuable.

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 efficiently structured in three sentences: first states purpose, second details capabilities and risks, third provides alternative usage. Every sentence adds critical information with zero waste.

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?

For a destructive tool with one parameter and no output schema, the description is complete: it explains what the tool does, when to use alternatives, behavioral side effects, and parameter intent. No gaps remain given the tool's complexity.

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 description coverage is 100%, so the schema already fully documents the 'text' parameter. The description repeats Unicode support but adds no additional parameter semantics beyond what's in the schema, meeting the baseline for high coverage.

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 specific action ('Type text at the current cursor position using clipboard paste') and resource ('text'), distinguishing it from sibling tools like press_key or clipboard_write by specifying its unique clipboard-based mechanism.

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?

It explicitly provides when-not-to-use guidance ('If secure input is active... returns a note suggesting clipboard_write + press_key as an alternative'), naming a specific alternative tool combination, which helps the agent choose correctly in different contexts.

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/antbotlab/mac-use-mcp'

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