Skip to main content
Glama
masx200
by masx200

webdav_read_remote_file

Read file content from remote WebDAV servers with options to extract specific line ranges using head or tail parameters for efficient data retrieval.

Instructions

Read content from a file on a remote WebDAV server with enhanced options (head/tail)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
headNoIf provided, returns only the first N lines of the file
pathYes
tailNoIf provided, returns only the last N lines of the file

Implementation Reference

  • Primary MCP tool implementation: registers the tool, defines input schema (path, optional head/tail lines), and executes by calling WebDAVService.readFileWithOptions with error handling.
    server.tool(
      "webdav_read_remote_file",
      "Read content from a file on a remote WebDAV server with enhanced options (head/tail)",
      {
        path: z.string().min(1, "Path must not be empty"),
        head: z.number().optional().describe(
          "If provided, returns only the first N lines of the file",
        ),
        tail: z.number().optional().describe(
          "If provided, returns only the last N lines of the file",
        ),
      },
      async ({ path, head, tail }) => {
        try {
          const content = await webdavService.readFileWithOptions(path, {
            head,
            tail,
          });
    
          // Build description for logging/debugging purposes
          const description = `Read file: ${path}${
            head ? ` (first ${head} lines)` : tail ? ` (last ${tail} lines)` : ""
          }`;
    
          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 for the tool: requires path, optional head/tail numbers for line limiting.
      path: z.string().min(1, "Path must not be empty"),
      head: z.number().optional().describe(
        "If provided, returns only the first N lines of the file",
      ),
      tail: z.number().optional().describe(
        "If provided, returns only the last N lines of the file",
      ),
    },
  • Supporting method in WebDAVService that implements the head/tail logic by reading full file content and slicing lines accordingly.
    async readFileWithOptions(
      path: string,
      options: { head?: number; tail?: number } = {},
    ): Promise<string> {
      const fullPath = this.getFullPath(path);
      logger.debug(`Reading file with options: ${fullPath}`, options);
    
      try {
        // Get the full file content first
        const content = await this.readFile(path);
    
        // If no head or tail specified, return full content
        if (!options.head && !options.tail) {
          return content;
        }
    
        // Cannot specify both head and tail
        if (options.head && options.tail) {
          throw new Error(
            "Cannot specify both head and tail parameters simultaneously",
          );
        }
    
        // Split content into lines
        const lines = content.split("\n");
    
        if (options.head) {
          // Return first N lines
          const headLines = lines.slice(0, options.head);
          const result = headLines.join("\n");
          logger.debug(`Read head of file: ${fullPath}`, {
            lines: headLines.length,
            requestedLines: options.head,
          });
          return result;
        }
    
        if (options.tail) {
          // Return last N lines
          const tailLines = lines.slice(-options.tail);
          const result = tailLines.join("\n");
          logger.debug(`Read tail of file: ${fullPath}`, {
            lines: tailLines.length,
            requestedLines: options.tail,
          });
          return result;
        }
    
        // This should never be reached due to earlier checks
        return content;
      } catch (error) {
        logger.error(`Error reading file with options ${fullPath}:`, error);
        throw new Error(
          `Failed to read file with options: ${(error as Error).message}`,
        );
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'enhanced options' but does not explain what 'read content' entails (e.g., text/binary handling, encoding, error behavior, or authentication requirements). This leaves critical behavioral traits unspecified for a file-reading operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose and includes key details. Every word earns its place, with no redundancy or unnecessary elaboration, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of file reading with options, no annotations, no output schema, and partial parameter coverage, the description is insufficient. It lacks details on return values, error handling, authentication, and how the tool differs from siblings, making it incomplete for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 67% (2 out of 3 parameters have descriptions), and the description adds minimal value by referencing 'head/tail' without explaining their interaction or default behaviors. It does not clarify if 'head' and 'tail' are mutually exclusive or how they work with the 'path' parameter, so it meets the baseline but does not compensate for the partial schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Read content from a file') and resource ('on a remote WebDAV server'), with the enhanced options ('head/tail') providing additional specificity. It distinguishes itself from the sibling 'webdav_get_remote_file' by emphasizing the head/tail functionality, though the distinction could be more explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'webdav_get_remote_file' or 'webdav_range_request'. It mentions enhanced options but does not specify scenarios where head/tail are preferred over other reading methods, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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