Skip to main content
Glama

clipboard_clear_clipboard

Clear clipboard content on macOS to remove sensitive data or prepare for new items using AppleScript automation.

Instructions

[Clipboard management operations] Clear clipboard content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler logic for the clear_clipboard tool. This script template is executed as AppleScript to clear the clipboard contents.
    {
      name: "clear_clipboard",
      description: "Clear clipboard content",
      script: `
        try
          set the clipboard to ""
          return "Clipboard cleared successfully"
        on error errMsg
          return "Failed to clear clipboard: " & errMsg
        end try
      `,
    },
  • Registers the 'clipboard_clear_clipboard' tool in the MCP listTools response by constructing the name from category 'clipboard' and script 'clear_clipboard'.
    // List available tools
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: this.categories.flatMap((category) =>
        category.scripts.map((script) => ({
          name: `${category.name}_${script.name}`, // Changed from dot to underscore
          description: `[${category.description}] ${script.description}`,
          inputSchema: script.schema || {
            type: "object",
            properties: {},
          },
        })),
      ),
    }));
  • src/index.ts:24-36 (registration)
    Registers the clipboardCategory (containing the clear_clipboard script) with the AppleScriptFramework server.
    console.error("[INFO] Registering categories...");
    server.addCategory(systemCategory);
    server.addCategory(calendarCategory);
    server.addCategory(finderCategory);
    server.addCategory(clipboardCategory);
    server.addCategory(notificationsCategory);
    server.addCategory(itermCategory);
    server.addCategory(mailCategory);
    server.addCategory(pagesCategory);
    server.addCategory(shortcutsCategory);
    server.addCategory(messagesCategory);
    server.addCategory(notesCategory);
    console.error(`[INFO] Registered ${11} categories successfully`);
  • The MCP tool call handler that parses 'clipboard_clear_clipboard', retrieves the clear_clipboard script from clipboard category, generates/executes the AppleScript, and returns the result.
    // Handle tool execution
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const toolName = request.params.name;
      this.log("info", "Tool execution requested", { 
        tool: toolName,
        hasArguments: !!request.params.arguments
      });
      
      try {
        // Split on underscore instead of dot
        const [categoryName, ...scriptNameParts] =
          toolName.split("_");
        const scriptName = scriptNameParts.join("_"); // Rejoin in case script name has underscores
    
        const category = this.categories.find((c) => c.name === categoryName);
        if (!category) {
          this.log("warning", "Category not found", { categoryName });
          throw new McpError(
            ErrorCode.MethodNotFound,
            `Category not found: ${categoryName}`,
          );
        }
    
        const script = category.scripts.find((s) => s.name === scriptName);
        if (!script) {
          this.log("warning", "Script not found", { 
            categoryName, 
            scriptName 
          });
          throw new McpError(
            ErrorCode.MethodNotFound,
            `Script not found: ${scriptName}`,
          );
        }
    
        this.log("debug", "Generating script content", { 
          categoryName, 
          scriptName,
          isFunction: typeof script.script === "function"
        });
        
        const scriptContent =
          typeof script.script === "function"
            ? script.script(request.params.arguments)
            : script.script;
    
        const result = await this.executeScript(scriptContent);
        
        this.log("info", "Tool execution completed successfully", { 
          tool: toolName,
          resultLength: result.length
        });
    
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      } catch (error) {
  • Helper function that executes the AppleScript generated by the clear_clipboard handler using osascript.
    private async executeScript(script: string): Promise<string> {
      // Log script execution (truncate long scripts for readability)
      const scriptPreview = script.length > 100 ? script.substring(0, 100) + "..." : script;
      this.log("debug", "Executing AppleScript", { scriptPreview });
      
      try {
        const startTime = Date.now();
        const { stdout } = await execAsync(
          `osascript -e '${script.replace(/'/g, "'\"'\"'")}'`,
        );
        const executionTime = Date.now() - startTime;
        
        this.log("debug", "AppleScript executed successfully", { 
          executionTimeMs: executionTime,
          outputLength: stdout.length
        });
        
        return stdout.trim();
      } catch (error) {
        // Properly type check the error object
        let errorMessage = "Unknown error occurred";
        if (error && typeof error === "object") {
          if ("message" in error && typeof error.message === "string") {
            errorMessage = error.message;
          } else if (error instanceof Error) {
            errorMessage = error.message;
          }
        } else if (typeof error === "string") {
          errorMessage = error;
        }
        
        this.log("error", "AppleScript execution failed", { 
          error: errorMessage,
          scriptPreview
        });
        
        throw new Error(`AppleScript execution failed: ${errorMessage}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Clear clipboard content') but doesn't mention side effects (e.g., permanent deletion, system permissions required, or error handling). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness3/5

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

The description is brief ('Clear clipboard content') and front-loaded, but it's overly concise to the point of being vague—it could benefit from slightly more detail without becoming verbose. The bracketed text '[Clipboard management operations]' adds minimal value and feels extraneous.

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 tool's complexity (a mutation operation with no annotations and no output schema), the description is incomplete. It lacks details on behavior, outcomes, or error conditions, making it inadequate for safe and effective use by an AI agent in this context.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add param info, which is acceptable here, but it doesn't fully compensate for other gaps, so a baseline 4 is assigned as it meets the minimum for zero-param tools.

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 action ('Clear') and resource ('clipboard content'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'clipboard_get_clipboard' or 'clipboard_set_clipboard' beyond the verb, which prevents a perfect score.

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 such as 'clipboard_set_clipboard' (which might overwrite content) or other clipboard operations. The description lacks context, prerequisites, or exclusions, offering minimal usage direction.

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/joshrutkowski/applescript-mcp'

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