Skip to main content
Glama
witqq

Clipboard MCP Server

by witqq

copy_paste

Copy or move content between files using text patterns. Find content by search patterns and insert at marker locations to edit files efficiently.

Instructions

Copy/paste content between files using text patterns. Find content by search pattern, insert at marker location.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes
targetYes
cutNoOptional: true to cut (move) instead of copy. Default: false

Implementation Reference

  • The main execute method implementing the copy/paste logic: extracts content from source by pattern, inserts into target at marker, optionally removes from source if cut=true.
    async execute(params: CopyPasteParams): Promise<CopyPasteResult> {
      try {
        await this.validateParams(params);
    
        // Extract content by pattern
        const contentToMove = await this.storageService.extractContentByPattern(
          params.source.file,
          params.source.start_pattern,
          params.source.end_pattern,
          params.source.line_count
        );
    
        let sourceModified = false;
        let targetModified = false;
    
        try {
          // Insert content by marker
          await this.storageService.insertContentByMarker(
            params.target.file,
            params.target.marker,
            contentToMove,
            params.target.position,
            params.target.replace_pattern
          );
          targetModified = true;
    
          // Remove from source if cut=true
          if (params.cut) {
            await this.storageService.removeContentByPattern(
              params.source.file,
              params.source.start_pattern,
              params.source.end_pattern,
              params.source.line_count
            );
            sourceModified = true;
          }
    
          return {
            success: true,
            message: `Successfully ${params.cut ? 'moved' : 'copied'} content`,
            contentMoved: contentToMove,
            sourceModified,
            targetModified
          };
    
        } catch (error) {
          return {
            success: false,
            message: `Operation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
            sourceModified,
            targetModified
          };
        }
    
      } catch (error) {
        return {
          success: false,
          message: `Validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          sourceModified: false,
          targetModified: false
        };
      }
    }
  • TypeScript interfaces defining the input parameters (CopyPasteParams) and output result (CopyPasteResult) for the copy_paste tool.
    export interface CopyPasteParams {
      source: SourceParams;
      target: TargetParams;
      cut?: boolean;
    }
    
    export interface CopyPasteResult {
      success: boolean;
      message: string;
      contentMoved?: string;
      sourceModified?: boolean;
      targetModified?: boolean;
    }
  • src/server.ts:46-104 (registration)
    Tool registration in ListToolsRequestHandler, defining name, description, and inputSchema for 'copy_paste'.
    {
      name: 'copy_paste',
      description: 'Copy/paste content between files using text patterns. Find content by search pattern, insert at marker location.',
      inputSchema: {
        type: 'object',
        properties: {
          source: {
            type: 'object',
            properties: {
              file: {
                type: 'string',
                description: 'Path to source file'
              },
              start_pattern: {
                type: 'string',
                description: 'Text pattern to find start of content to copy (e.g., "function processData", "// Section start")'
              },
              end_pattern: {
                type: 'string',
                description: 'Optional: text pattern for end of content. If not provided, uses line_count'
              },
              line_count: {
                type: 'number', 
                description: 'Optional: number of lines to copy from start_pattern. Default: 1'
              }
            },
            required: ['file', 'start_pattern']
          },
          target: {
            type: 'object',
            properties: {
              file: {
                type: 'string',
                description: 'Path to target file'
              },
              marker: {
                type: 'string',
                description: 'Text pattern to find insertion point (e.g., "// Insert here", "class MyClass")'
              },
              position: {
                type: 'string',
                enum: ['before', 'after', 'replace'],
                description: 'Where to insert relative to marker: before, after, or replace the marker'
              },
              replace_pattern: {
                type: 'string',
                description: 'Optional: specific text pattern to replace (when position=replace)'
              }
            },
            required: ['file', 'marker', 'position']
          },
          cut: {
            type: 'boolean',
            description: 'Optional: true to cut (move) instead of copy. Default: false'
          }
        },
        required: ['source', 'target']
      }
    }
  • src/server.ts:112-144 (registration)
    Dispatch logic in CallToolRequestHandler that casts arguments to CopyPasteParams and calls the handler's execute method.
    if (name === 'copy_paste') {
      try {
        // Валидация и типизация входных аргументов
        if (!args || typeof args !== 'object') {
          throw new Error('Invalid arguments provided');
        }
        
        const params = args as unknown as CopyPasteParams;
        const result = await this.copyPasteHandler.execute(params);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: false,
                message: `Tool execution error: ${error instanceof Error ? error.message : 'Unknown error'}`
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
  • src/server.ts:37-37 (registration)
    Instantiation of the CopyPasteHandler with storage service dependency.
    this.copyPasteHandler = new CopyPasteHandler(storageService);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'copy/paste' and 'cut' in parameters, implying file modification, but doesn't disclose critical behaviors like whether it creates backups, handles errors, requires file permissions, or has side effects. For a file manipulation tool with zero annotation coverage, this is inadequate.

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 extremely concise with two sentences that directly address the tool's function. Every word earns its place, and it's front-loaded with the core purpose. No wasted verbiage or redundancy.

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?

For a file manipulation tool with 3 parameters (including nested objects), no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on behavior, error handling, return values, and practical usage scenarios, leaving significant gaps for an AI agent.

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 33% (low), but the description adds minimal value beyond the schema. It mentions 'Find content by search pattern, insert at marker location,' which loosely maps to source.start_pattern and target.marker, but doesn't explain parameter interactions, defaults, or edge cases. The description partially compensates for low schema coverage but not sufficiently.

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's purpose: 'Copy/paste content between files using text patterns.' It specifies the verb (copy/paste), resource (content between files), and mechanism (text patterns). However, with no sibling tools provided, it cannot demonstrate differentiation from alternatives.

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 guidance on when to use this tool versus alternatives, prerequisites, or constraints. It only describes what the tool does, not when it's appropriate. With no sibling tools, it cannot offer comparative advice.

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/witqq/clipboard-mcp'

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