Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_get_remote_file

Retrieve content from files stored on remote WebDAV servers by specifying the file path to access and download data.

Instructions

Retrieve content from a file stored on a remote WebDAV server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The MCP tool handler function that executes the webdav_get_remote_file logic by calling WebDAVService.readFile(path) and returning the content or error.
    async ({ path }) => { try { const content = await webdavService.readFile(path); return { content: [{ type: 'text', text: content }] }; } catch (error) { return { content: [{ type: 'text', text: `Error reading file: ${(error as Error).message}` }], isError: true }; } }
  • Zod input schema validation for the tool parameters.
    { path: z.string().min(1, 'Path must not be empty') },
  • Registration of the webdav_get_remote_file tool with MCP server.tool, including name, description, schema, and handler reference.
    server.tool( 'webdav_get_remote_file', 'Retrieve content from a file stored on a remote WebDAV server', { path: z.string().min(1, 'Path must not be empty') }, async ({ path }) => { try { const content = await webdavService.readFile(path); return { content: [{ type: 'text', text: content }] }; } catch (error) { return { content: [{ type: 'text', text: `Error reading file: ${(error as Error).message}` }], isError: true }; } } );
  • Core implementation of file reading in WebDAVService using WebDAVClient.getFileContents with text format, handling various response types.
    async readFile(path: string): Promise<string> { const fullPath = this.getFullPath(path); logger.debug(`Reading file: ${fullPath}`); try { // v5.x returns buffer by default, need to use format: 'text' const content = await this.client.getFileContents(fullPath, { format: 'text' }); // Handle both direct string response and detailed response let result: string; if (typeof content === 'string') { result = content; } else if (this.isResponseData(content)) { result = String(content.data); } else { throw new Error("Unexpected response format from server"); } const contentLength = result.length; logger.debug(`Read file: ${fullPath}`, { contentLength }); return result; } catch (error) { logger.error(`Error reading file ${fullPath}:`, error); throw new Error(`Failed to read file: ${(error as Error).message}`); } }

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