Skip to main content
Glama

collect_pasted_items

Opens a popup to paste clipboard content like images, Excel tables, or text into Claude for analysis and discussion.

Instructions

Opens a Windows popup to let the user paste images, Excel tables, rich text, or plain text from their clipboard. Use this when the user indicates they want to attach content (e.g. via @pic).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prompt_contextNoOptional context about what the user is expected to paste.

Implementation Reference

  • The server request handler for CallToolRequestSchema handles the 'collect_pasted_items' tool by calling the runPowerShellPopup function and formatting the result.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== TOOL_NAME) {
        throw new Error(`Unknown tool: ${request.params.name}`);
      }
      debugLog("=== Tool called: collect_pasted_items ===");
      try {
        const items = await runPowerShellPopup();
        debugLog(`Received ${items.length} items from popup`);
        
        // If empty array, treat as cancel
        if (!items || items.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "User cancelled the paste operation or no items were confirmed.",
              },
            ],
          };
        }
        // Group items by type
        const images = items.filter(i => i.type === "image");
        const tables = items.filter(i => i.type === "table");
        const richtext = items.filter(i => i.type === "richtext");
        const text = items.filter(i => i.type === "text");
    
        // Build friendly summary
        const parts = [];
        if (images.length > 0) {
          parts.push(`${images.length} image${images.length > 1 ? 's' : ''}`);
        }
        if (tables.length > 0) {
          parts.push(`${tables.length} table${tables.length > 1 ? 's' : ''}`);
        }
        if (richtext.length > 0) {
          parts.push(`${richtext.length} rich text item${richtext.length > 1 ? 's' : ''}`);
        }
        if (text.length > 0) {
          parts.push(`${text.length} text item${text.length > 1 ? 's' : ''}`);
        }
    
        const count = items.length;
        const itemNames = items.map(i => i.name).join(", ");
        const summaryText = `[${parts.join(', ')} attached: ${itemNames}]`;
    
        // Build machine-readable JSON block
        const jsonBlock = `ITEMS_JSON: ${JSON.stringify(items)}`;
        return {
          content: [
            {
              type: "text",
              text: summaryText,
            },
            {
              type: "text",
              text: jsonBlock,
            }
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error collecting items: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    });
  • src/index.js:33-51 (registration)
    The server request handler for ListToolsRequestSchema registers the 'collect_pasted_items' tool definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: TOOL_NAME,
            description: "Opens a Windows popup to let the user paste images, Excel tables, rich text, or plain text from their clipboard. Use this when the user indicates they want to attach content (e.g. via @pic).",
            inputSchema: {
              type: "object",
              properties: {
                prompt_context: {
                  type: "string",
                  description: "Optional context about what the user is expected to paste."
                }
              },
            },
          },
        ],
      };
    });
  • The 'runPowerShellPopup' function acts as a helper that spawns a PowerShell process to retrieve clipboard content.
    function runPowerShellPopup() {
      return new Promise((resolve, reject) => {
        const ps = spawn("powershell", [
          "-NoProfile",
          "-ExecutionPolicy", "Bypass",
          "-File", POWERSHELL_SCRIPT
        ], {
          // Ensure proper encoding
          env: { ...process.env, PYTHONIOENCODING: 'utf-8' }
        });
        let stdoutData = "";
        let stderrData = "";
        ps.stdout.on("data", (data) => {
          stdoutData += data.toString();
        });
        ps.stderr.on("data", (data) => {
          stderrData += data.toString();
        });
        ps.on("close", (code) => {
          debugLog(`Exit code: ${code}`);
          debugLog(`stdout length: ${stdoutData.length}`);
          debugLog(`stdout: ${stdoutData.substring(0, 1000)}`);
          debugLog(`stderr: ${stderrData}`);
    
          if (stderrData && code !== 0) {
            debugLog(`PS Error: ${stderrData}`);
          }
          const trimmed = stdoutData.trim();
          if (!trimmed) {
            debugLog("Empty output, resolving []");
            resolve([]);
            return;
          }
          try {
            const lines = trimmed.split('\n');
            const lastLine = lines[lines.length - 1].trim();
            debugLog(`Parsing last line: ${lastLine.substring(0, 500)}`);
            const result = JSON.parse(lastLine);
    
            if (Array.isArray(result)) {
              debugLog(`Parsed array with ${result.length} items`);
              resolve(result);
            } else {
              debugLog("Parsed single object, wrapping in array");
              resolve([result]);
            }
          } catch (e) {
            debugLog(`Parse error: ${e.message}`);
            debugLog(`Raw output: ${trimmed}`);
            resolve([]);
          }
        });
      });
Behavior3/5

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

With no annotations provided, the description carries the full burden. It successfully discloses the UI interaction model (Windows popup) and supported data formats, but lacks details on return values, blocking behavior, or failure modes (e.g., user cancellation), leaving gaps in behavioral disclosure.

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?

Two sentences with zero redundancy: the first establishes capability and mechanism, the second provides usage conditions with an example. Perfectly front-loaded and economically structured.

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 100% schema coverage and the tool's narrow scope, the description adequately covers the interaction model and supported formats. Minor deduction for lacking mention of return behavior or error states given the absence of an output schema, but sufficient for correct invocation.

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% (one optional parameter fully documented), establishing a baseline of 3. The description does not add supplementary details, examples, or semantic clarifications beyond what the schema already provides for 'prompt_context'.

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 provides a specific action ('Opens a Windows popup'), clearly identifies the resource (clipboard content), and enumerates supported formats (images, Excel tables, rich text, plain text), leaving no ambiguity about the tool's function.

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?

Explicitly states when to use the tool ('when the user indicates they want to attach content') and provides a concrete example trigger ('e.g. via @pic'), giving the agent clear signals for invocation without ambiguity.

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/G3sparky/claude-paste-mcp'

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