Skip to main content
Glama
masx200
by masx200

webdav_get_file_info

Retrieve detailed metadata about files and directories on WebDAV servers, including file properties, size, modification dates, and directory contents for comprehensive file system management.

Instructions

Get detailed metadata about a file or directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Core handler implementation for webdav_get_file_info tool. Registers the tool with schema, executes webdavService.stat(path), formats output using formatSize, and returns structured text response or error.
    server.tool(
      "webdav_get_file_info",
      "Get detailed metadata about a file or directory",
      {
        path: z.string().min(1, "Path must not be empty"),
      },
      async ({ path }) => {
        try {
          const stats = await webdavService.stat(path);
    
          const info = {
            name: stats.basename,
            path: stats.filename,
            type: stats.type,
            size: stats.size || 0,
            sizeFormatted: formatSize(stats.size || 0),
            lastModified: stats.lastmod,
            mimeType: stats.mime,
          };
    
          return {
            content: [{
              type: "text",
              text: Object.entries(info)
                .map(([key, value]) => `${key}: ${value}`)
                .join("\n"),
            }],
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error getting file info: ${(error as Error).message}`,
            }],
            isError: true,
          };
        }
      },
    );
  • src/lib.ts:79-79 (registration)
    Calls setupToolHandlers which registers the webdav_get_file_info tool among others on the MCP server.
    setupToolHandlers(server, webdavService);
  • Helper function to format file sizes in human-readable form, used in the tool's output.
    // Helper function to format file size
    function formatSize(bytes: number): string {
      const units = ["B", "KB", "MB", "GB", "TB"];
      if (bytes === 0) return "0 B";
    
      const i = Math.floor(Math.log(bytes) / Math.log(1024));
    
      if (i < 0 || i === 0) return `${bytes} ${units[0]}`;
    
      const unitIndex = Math.min(i, units.length - 1);
      return `${(bytes / Math.pow(1024, unitIndex)).toFixed(2)} ${
        units[unitIndex]
      }`;
    }
  • WebDAVService.stat method called by the tool handler to retrieve file/directory metadata from the WebDAV server.
    async stat(path: string): Promise<FileStat> {
      const fullPath = this.getFullPath(path);
      logger.debug(`Getting stats for: ${fullPath}`);
    
      try {
        const result = await this.client.stat(fullPath);
    
        // Convert the result to our FileStat interface
        const stats = this.convertToFileStat(
          this.isResponseData(result) ? result.data : result,
        );
    
        logger.debug(`Got stats for: ${fullPath}`, { type: stats.type });
        return stats;
      } catch (error) {
        logger.error(`Error getting stats for ${fullPath}:`, error);
        throw new Error(`Failed to get file stats: ${(error as Error).message}`);
      }
    }
  • Type definition for FileStat returned by stat method, used to structure the tool's output.
    export interface FileStat {
      filename: string;
      basename: string;
      lastmod?: string;
      size?: number;
      type: "file" | "directory";
      mime?: string;
      [key: string]: any;
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 states the tool retrieves metadata, implying a read-only operation, but doesn't specify what 'detailed metadata' includes (e.g., size, timestamps, permissions), whether it handles errors for non-existent paths, or if there are rate limits. This leaves significant gaps in understanding how the tool behaves in practice.

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 directly states the tool's function without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. Every part of the sentence contributes essential information, earning its place.

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 a WebDAV metadata tool with no annotations, no output schema, and low schema coverage, the description is insufficient. It doesn't explain what metadata is returned, error conditions, or how it integrates with sibling tools. For a tool that could involve file system interactions, more context on behavior and output is needed for effective 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 input schema has 1 parameter with 0% description coverage, so the description must compensate. It mentions 'path' implicitly but doesn't explain what the path represents (e.g., absolute vs. relative, format requirements) or provide examples. Since there's only one parameter, the baseline is 4, but the lack of any parameter details in the description reduces this to 3, as it adds minimal value beyond the schema.

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 ('Get detailed metadata') and resource ('about a file or directory'), making the purpose immediately understandable. It distinguishes itself from siblings like webdav_get_remote_file (which retrieves file content) and webdav_list_remote_directory (which lists directory contents). However, it doesn't explicitly contrast with webdav_get_directory_tree, which might also provide metadata in a tree structure.

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. For example, it doesn't clarify if this should be used instead of webdav_list_directory_with_sizes for individual items or how it differs from webdav_get_directory_tree. There's no mention of prerequisites, such as needing read permissions, or typical use cases like checking file properties before operations.

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