webdav_get_remote_file
Retrieve content from files stored on remote WebDAV servers by specifying the file path, enabling access to remote file data through simple path-based requests.
Instructions
Retrieve content from a file stored on a remote WebDAV server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/handlers/tool-handlers.ts:54-80 (registration)MCP server.tool call that registers the webdav_get_remote_file tool, provides its description, input schema using Zod, and defines the inline execution handler.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, }; } }, );
- The WebDAVService.readFile method implements the core file reading logic using WebDAVClient.getFileContents with text format, handles response formats, and includes logging and error handling. This is called by the tool handler.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}`); } }
- src/lib.ts:79-79 (registration)Top-level call to setupToolHandlers which registers all WebDAV tools, including webdav_get_remote_file, on the MCP server instance.setupToolHandlers(server, webdavService);