Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_list_remote_directory

List files and directories from a remote WebDAV server path to view available content and navigate the file system.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo/

Implementation Reference

  • MCP tool handler implementation for 'webdav_list_remote_directory'. Registers the tool with Zod input schema (path optional, defaults to '/'), executes webdavService.list(path), formats results as JSON, and returns as text content or error.
    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 }; } } );
  • Core helper method implementing directory listing using WebDAVClient.getDirectoryContents, handling response formats, converting to FileStat[], with full path resolution and logging.
    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)
    Top-level server initialization calls setupToolHandlers(server, webdavService), which registers the 'webdav_list_remote_directory' tool among others.
    setupResourceHandlers(server, webdavService); setupToolHandlers(server, webdavService); setupPromptHandlers(server);
  • Zod input schema for the tool: path as optional string defaulting to '/'.
    { path: z.string().optional().default('/') },
  • Supporting utility for basename extraction used in FileStat conversion.
    private getBasenameFromPath(path: string): string {

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