Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_copy_remote_item

Copy files or directories to a new location on a remote WebDAV server, allowing controlled overwrite options for efficient file management.

Instructions

Copy a file or directory to a new location on a remote WebDAV server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromPathYes
overwriteNo
toPathYes

Implementation Reference

  • Primary handler implementation for the webdav_copy_remote_item tool. Registers the tool with the MCP server, defines input schema using Zod, performs validation and existence checks, executes the copy via WebDAVService, and handles errors with appropriate responses.
    'webdav_copy_remote_item', 'Copy a file or directory to a new location on a remote WebDAV server', { fromPath: z.string().min(1, 'Source path must not be empty'), toPath: z.string().min(1, 'Destination path must not be empty'), overwrite: z.boolean().optional().default(false) }, async ({ fromPath, toPath, overwrite }) => { try { // Check if source exists const sourceExists = await webdavService.exists(fromPath); if (!sourceExists) { return { content: [{ type: 'text', text: `Error: Source path does not exist at ${fromPath}` }], isError: true }; } // Check if destination exists and respect overwrite flag const destExists = await webdavService.exists(toPath); if (destExists && !overwrite) { return { content: [{ type: 'text', text: `Error: Destination already exists at ${toPath}. Use overwrite=true to replace it.` }], isError: true }; } await webdavService.copy(fromPath, toPath); return { content: [{ type: 'text', text: `Successfully copied ${fromPath} to ${toPath}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error copying: ${(error as Error).message}` }], isError: true }; } }
  • Zod input schema for the webdav_copy_remote_item tool defining parameters: fromPath (string), toPath (string), overwrite (boolean optional default false).
    { fromPath: z.string().min(1, 'Source path must not be empty'), toPath: z.string().min(1, 'Destination path must not be empty'), overwrite: z.boolean().optional().default(false) },
  • Core helper method in WebDAVService class that performs the actual file/directory copy operation using WebDAVClient.copyFile(), including path normalization, logging, error handling, and result validation.
    async copy(fromPath: string, toPath: string): Promise<void> { const fullFromPath = this.getFullPath(fromPath); const fullToPath = this.getFullPath(toPath); logger.debug(`Copying from ${fullFromPath} to ${fullToPath}`); try { // Get type before copying for better logging const stat = await this.stat(fromPath).catch(() => null); const itemType = stat?.type || 'item'; // copyFile in v5.x returns a boolean indicating success const result = await this.client.copyFile(fullFromPath, fullToPath); // Check result based on type if (typeof result === 'boolean' && !result) { throw new Error("Failed to copy: server returned failure status"); } else if (this.isResponseData(result) && result.status !== undefined && result.status !== 201 && result.status !== 204) { throw new Error(`Failed to copy: server returned status ${result.status}`); } logger.debug(`Successfully copied ${itemType} from ${fullFromPath} to ${fullToPath}`); } catch (error) { logger.error(`Error copying from ${fullFromPath} to ${fullToPath}:`, error); throw new Error(`Failed to copy: ${(error as Error).message}`); } }
  • src/lib.ts:78-78 (registration)
    High-level registration call in main server startup that invokes setupToolHandlers to register all WebDAV tools, including webdav_copy_remote_item.
    setupToolHandlers(server, webdavService);

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/LaubPlusCo/mcp-webdav-server'

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