Skip to main content
Glama

copy_items

Copies multiple files or directories from specified sources to destinations in a TypeScript-based filesystem, using a defined array of source-destination pairs.

Instructions

Copy multiple specified files/directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationsYesArray of {source, destination} objects.

Implementation Reference

  • Main handler function `handleCopyItemsFunc` that orchestrates multiple copy operations: parses and validates input, maps to concurrent promises, awaits settled results, processes and sorts them by original order, and returns JSON stringified results.
    const handleCopyItemsFunc = async (args: unknown): Promise<McpToolResponse> => { const { operations } = parseAndValidateArgs(args); const copyPromises = operations.map((op) => processSingleCopyOperation({ op })); const settledResults = await Promise.allSettled(copyPromises); const outputResults = processSettledResults(settledResults, operations); // Sort results based on the original order const originalIndexMap = new Map(operations.map((op, i) => [op.source.replaceAll('\\', '/'), i])); outputResults.sort((a, b) => { const indexA = originalIndexMap.get(a.source) ?? Infinity; const indexB = originalIndexMap.get(b.source) ?? Infinity; return indexA - indexB; }); return { content: [{ type: 'text', text: JSON.stringify(outputResults, undefined, 2) }], }; };
  • Zod schemas: `CopyOperationSchema` for individual source/destination pairs and `CopyItemsArgsSchema` for the tool input (array of operations, min 1).
    export const CopyOperationSchema = z .object({ source: z.string().describe('Relative path of the source.'), destination: z.string().describe('Relative path of the destination.'), }) .strict(); export const CopyItemsArgsSchema = z .object({ operations: z .array(CopyOperationSchema) .min(1, { message: 'Operations array cannot be empty' }) .describe('Array of {source, destination} objects.'), }) .strict();
  • Tool definition `copyItemsToolDefinition` that registers the tool with name 'copy_items', description, input schema, and handler function.
    export const copyItemsToolDefinition = { name: 'copy_items', description: 'Copy multiple specified files/directories.', inputSchema: CopyItemsArgsSchema, handler: handleCopyItemsFunc, };
  • Import statement bringing in the copyItemsToolDefinition for registration.
    import { copyItemsToolDefinition } from './copy-items.js';
  • Inclusion of `copyItemsToolDefinition` in the `allToolDefinitions` array, serving as the central registration point for all handler tools.
    copyItemsToolDefinition,

Other Tools

Related 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/SylphxAI/filesystem-mcp'

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