Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_delete_remote_item

Remove a file or directory from a remote WebDAV server by specifying its path, enabling efficient management of WebDAV file systems.

Instructions

Delete a file or directory from a remote WebDAV server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The core handler implementation for the 'webdav_delete_remote_item' tool. Registers the tool with MCP server, defines input schema, and implements the logic: checks existence, deletes via WebDAVService, handles errors.
    server.tool( 'webdav_delete_remote_item', 'Delete a file or directory from a remote WebDAV server', { path: z.string().min(1, 'Path must not be empty') }, async ({ path }) => { try { // Check if path exists const exists = await webdavService.exists(path); if (!exists) { return { content: [{ type: 'text', text: `Error: Path does not exist at ${path}` }], isError: true }; } await webdavService.delete(path); return { content: [{ type: 'text', text: `Successfully deleted ${path}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error deleting: ${(error as Error).message}` }], isError: true }; } } );
  • Helper method in WebDAVService that performs the actual deletion by calling the WebDAV client's deleteFile method, handles path normalization, logging, and error checking.
    async delete(path: string): Promise<void> { const fullPath = this.getFullPath(path); logger.debug(`Deleting: ${fullPath}`); try { // Get type before deleting for better logging const stat = await this.stat(fullPath).catch(() => null); const itemType = stat?.type || 'item'; // deleteFile in v5.x returns a boolean indicating success const result = await this.client.deleteFile(fullPath); // Check result based on type if (typeof result === 'boolean' && !result) { throw new Error("Failed to delete: server returned failure status"); } else if (this.isResponseData(result) && result.status !== undefined && result.status !== 204) { throw new Error(`Failed to delete: server returned status ${result.status}`); } logger.debug(`Successfully deleted ${itemType}: ${fullPath}`); } catch (error) { logger.error(`Error deleting ${fullPath}:`, error); throw new Error(`Failed to delete: ${(error as Error).message}`); } }
  • src/lib.ts:77-78 (registration)
    Registration of handlers during server startup. setupToolHandlers registers all tools including 'webdav_delete_remote_item'.
    setupResourceHandlers(server, webdavService); setupToolHandlers(server, webdavService);
  • Input schema validation using Zod for the tool parameters.
    { path: z.string().min(1, 'Path must not be empty') },
  • Related prompt registration for 'webdav_delete_remote_item' which generates messages for LLM interaction.
    server.prompt( 'webdav_delete_remote_item', // The issue is with boolean not being compatible with the prompt schema // Using string as a workaround { path: z.string().min(1, 'Path must not be empty'), confirm: z.string().optional() }, (args) => { const confirmationEnabled = args.confirm !== 'false'; const pathValue = args.path; const isDirectory = pathValue.endsWith('/'); return { messages: [ { role: 'user', content: { type: 'text', text: `Delete the ${isDirectory ? 'directory' : 'file'} at "${pathValue}" from the remote WebDAV server. ${confirmationEnabled ? 'Please confirm this action to proceed with deletion.' : 'Execute this remote deletion operation.'} Please confirm when the remote WebDAV deletion is complete.` } } ] }; } );

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