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
| Name | Required | Description | Default |
|---|---|---|---|
| operations | Yes | Array of {source, destination} objects. |
Implementation Reference
- src/handlers/copy-items.ts:167-186 (handler)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) }], }; };
- src/handlers/copy-items.ts:11-25 (schema)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();
- src/handlers/copy-items.ts:189-194 (registration)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, };
- src/handlers/index.ts:10-10 (registration)Import statement bringing in the copyItemsToolDefinition for registration.import { copyItemsToolDefinition } from './copy-items.js';
- src/handlers/index.ts:58-58 (registration)Inclusion of `copyItemsToolDefinition` in the `allToolDefinitions` array, serving as the central registration point for all handler tools.copyItemsToolDefinition,