Skip to main content
Glama

clipboard_write

Write text to the macOS clipboard for desktop automation tasks, enabling AI agents to copy data programmatically.

Instructions

Write text to the macOS clipboard.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to write to the clipboard.

Implementation Reference

  • The handler function that processes the clipboard_write tool request.
    async function handleClipboardWrite(
      args: Record<string, unknown>,
    ): Promise<CallToolResult> {
      const parsed = ClipboardWriteInputSchema.parse(args);
      await clipboardWrite(parsed.text);
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify({
              success: true,
              length: parsed.text.length,
            }),
          },
        ],
      };
    }
  • Input schema validation for clipboard_write.
    const ClipboardWriteInputSchema = z.object({
      text: z.string().max(100_000).describe("Text to write to the clipboard."),
    });
  • Tool definition for clipboard_write registration.
    {
      name: "clipboard_write",
      description: "Write text to the macOS clipboard.",
      inputSchema: zodToToolInputSchema(ClipboardWriteInputSchema),
      annotations: {
        readOnlyHint: false,
        destructiveHint: false,
      },
    },
  • Core utility that interfaces with macOS 'pbcopy' to write to the clipboard.
    export async function clipboardWrite(text: string): Promise<void> {
      await new Promise<void>((resolve, reject) => {
        const proc = execFile(
          "pbcopy",
          [],
          { timeout: CLIPBOARD_TIMEOUT_MS },
          (error: Error | null) => {
            if (error) {
              reject(error);
            } else {
              resolve();
            }
          },
        );
    
        if (!proc.stdin) {
          reject(new Error("Failed to open stdin for pbcopy"));
          return;
        }
    
        proc.stdin.write(text);
        proc.stdin.end();
      });
    }
Behavior3/5

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

Annotations indicate this is not read-only and not destructive, which the description doesn't contradict. The description adds context about the target platform (macOS) and the action (writing text), but doesn't provide additional behavioral details like whether it overwrites existing clipboard content, requires specific permissions, or has rate limits. With annotations covering basic safety, this earns a baseline score.

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 a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable without unnecessary elaboration.

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 tool's simplicity (one parameter, no output schema, annotations present), the description is mostly complete. It specifies the platform (macOS) and action, but could benefit from mentioning what happens to existing clipboard content or any system dependencies. However, for a basic write operation, it's sufficient.

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%, with the single parameter 'text' fully documented in the schema. The description doesn't add any parameter-specific details beyond what the schema provides, such as examples or constraints beyond maxLength. This meets the baseline for high schema 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 ('write text') and target resource ('macOS clipboard'), distinguishing it from sibling tools like clipboard_read (which reads) and type_text (which types). It uses a precise verb+resource combination that leaves no ambiguity about its function.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'macOS clipboard', which suggests this tool is for clipboard operations on macOS systems. However, it doesn't explicitly state when to use this versus alternatives like type_text for direct text input or when clipboard operations might fail due to permissions or system constraints.

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