Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_move_remote_item

Move or rename files and directories on a remote WebDAV server by specifying source and destination paths, with optional overwrite control.

Instructions

Move or rename a file or directory on a remote WebDAV server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromPathYes
toPathYes
overwriteNo

Implementation Reference

  • Registers the 'webdav_move_remote_item' tool with input schema validation and execution handler that performs existence checks and calls webdavService.move()
    server.tool(
      'webdav_move_remote_item',
      'Move or rename a file or directory 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.move(fromPath, toPath);
          
          return {
            content: [{
              type: 'text',
              text: `Successfully moved ${fromPath} to ${toPath}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error moving: ${(error as Error).message}`
            }],
            isError: true
          };
        }
      }
    );
  • Implements the move operation in WebDAVService by calling WebDAVClient.moveFile with path normalization and error handling
    async move(fromPath: string, toPath: string): Promise<void> {
      const fullFromPath = this.getFullPath(fromPath);
      const fullToPath = this.getFullPath(toPath);
      logger.debug(`Moving from ${fullFromPath} to ${fullToPath}`);
      
      try {
        // Get type before moving for better logging
        const stat = await this.stat(fromPath).catch(() => null);
        const itemType = stat?.type || 'item';
        
        // moveFile in v5.x returns a boolean indicating success
        const result = await this.client.moveFile(fullFromPath, fullToPath);
        
        // Check result based on type
        if (typeof result === 'boolean' && !result) {
          throw new Error("Failed to move: server returned failure status");
        } else if (this.isResponseData(result) && 
                   result.status !== undefined && 
                   result.status !== 201 && 
                   result.status !== 204) {
          throw new Error(`Failed to move: server returned status ${result.status}`);
        }
        
        logger.debug(`Successfully moved ${itemType} from ${fullFromPath} to ${fullToPath}`);
      } catch (error) {
        logger.error(`Error moving from ${fullFromPath} to ${fullToPath}:`, error);
        throw new Error(`Failed to move: ${(error as Error).message}`);
      }
    }
  • src/lib.ts:77-79 (registration)
    Top-level server setup calls setupToolHandlers(server, webdavService) which registers the webdav_move_remote_item tool among others
    setupResourceHandlers(server, webdavService);
    setupToolHandlers(server, webdavService);
    setupPromptHandlers(server);
  • Input schema for the webdav_move_remote_item tool using Zod validation
      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)
    },

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