Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_copy_remote_item

Copy files or directories between locations on a remote WebDAV server. Specify source and destination paths to duplicate items within the server's file system.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromPathYes
toPathYes
overwriteNo

Implementation Reference

  • Registers and implements the 'webdav_copy_remote_item' MCP tool handler. Defines input schema with Zod, performs pre-copy validation (source/dest existence, overwrite check), executes the copy via WebDAVService, and returns formatted success/error 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 parameters.
    { 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 copy implementation in WebDAVService class. Normalizes paths, logs operation, performs copy using WebDAVClient.copyFile, validates response, handles errors.
    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)
    Top-level call to setupToolHandlers which registers 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