Skip to main content
Glama

webdav_read_multiple_files

Read contents from multiple WebDAV files simultaneously to efficiently access and process multiple documents at once, saving time on individual file operations.

Instructions

Read the contents of multiple files simultaneously

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYesArray of file paths to read

Implementation Reference

  • The primary MCP tool handler implementation for 'webdav_read_multiple_files'. Includes tool registration with server.tool, input schema validation using Zod (paths: array of strings), execution logic that calls the service method, formats results with separators and error handling, and returns structured MCP response.
    server.tool( "webdav_read_multiple_files", "Read the contents of multiple files simultaneously", { paths: z.array(z.string()).min( 1, "At least one file path must be provided", ).describe("Array of file paths to read"), }, async ({ paths }) => { try { const results = await webdavService.readMultipleFiles(paths); const formattedResults = results.map((result) => { if (result.error) { return `${result.path}: Error - ${result.error}`; } else { return `${result.path}:\n${result.content}\n`; } }); return { content: [{ type: "text", text: formattedResults.join("\n---\n"), }], }; } catch (error) { return { content: [{ type: "text", text: `Error reading multiple files: ${(error as Error).message}`, }], isError: true, }; } }, );
  • Supporting utility method in WebDAVService class that implements the core logic for reading multiple files concurrently using Promise.allSettled, individual readFile calls, and returns array of results with path, content or error.
    async readMultipleFiles( paths: string[], ): Promise<{ path: string; content?: string; error?: string }[]> { logger.debug(`Reading multiple files`, { count: paths.length }); const results = await Promise.allSettled( paths.map(async (path) => { try { const content = await this.readFile(path); return { path, content }; } catch (error) { return { path, error: (error as Error).message, }; } }), ); const formattedResults = results.map((result) => result.status === "fulfilled" ? result.value : { path: "", error: "Unknown error" } ); logger.debug(`Multiple files read completed`, { success: formattedResults.filter((r) => !r.error).length, failed: formattedResults.filter((r) => r.error).length, }); return formattedResults; }

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/masx200/mcp-webdav-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server