Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_list_remote_directory

Retrieve and list files and directories from a specified path on a remote WebDAV server to manage and organize your remote file system.

Instructions

List files and directories at the specified path on a remote WebDAV server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo/

Implementation Reference

  • The core handler function that executes the tool: fetches directory listing from WebDAV service, formats files with name/path/type/size/lastmod, returns JSON text or error.
    async ({ path }) => { try { const files = await webdavService.list(path); // Format response const formattedFiles = files.map(file => ({ name: file.basename, path: file.filename, type: file.type, size: file.size, lastModified: file.lastmod })); return { content: [{ type: 'text', text: JSON.stringify(formattedFiles, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `Error listing directory: ${(error as Error).message}` }], isError: true }; } }
  • Input validation schema using Zod: path as optional string defaulting to root directory '/'.
    { path: z.string().optional().default('/') },
  • MCP server.tool registration of the webdav_list_remote_directory tool with description, schema, and handler function.
    server.tool( 'webdav_list_remote_directory', 'List files and directories at the specified path on a remote WebDAV server', { path: z.string().optional().default('/') }, async ({ path }) => { try { const files = await webdavService.list(path); // Format response const formattedFiles = files.map(file => ({ name: file.basename, path: file.filename, type: file.type, size: file.size, lastModified: file.lastmod })); return { content: [{ type: 'text', text: JSON.stringify(formattedFiles, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `Error listing directory: ${(error as Error).message}` }], isError: true }; } } );
  • WebDAVService.list method: core implementation using WebDAVClient.getDirectoryContents, path normalization, response conversion to FileStat array, error handling.
    async list(path: string = '/'): Promise<FileStat[]> { const fullPath = this.getFullPath(path); logger.debug(`Listing directory: ${fullPath}`); try { // In v5.x we need to handle the response differently const result = await this.client.getDirectoryContents(fullPath); // Convert the result to our FileStat interface const fileStats = Array.isArray(result) ? result.map(item => this.convertToFileStat(item)) : this.isResponseData(result) && Array.isArray(result.data) ? result.data.map(item => this.convertToFileStat(item)) : []; logger.debug(`Listed ${fileStats.length} items in directory: ${fullPath}`); return fileStats; } catch (error) { logger.error(`Error listing directory ${fullPath}:`, error); throw new Error(`Failed to list directory: ${(error as Error).message}`); } }
  • src/lib.ts:77-79 (registration)
    Calls to setup functions in lib.ts startWebDAVServer that invoke the handler setups including tool registration for webdav_list_remote_directory.
    setupResourceHandlers(server, webdavService); setupToolHandlers(server, webdavService); setupPromptHandlers(server);

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