Skip to main content
Glama
masx200
by masx200

webdav_list_remote_directory

Browse and view files and directories stored on a remote WebDAV server to manage your cloud storage content and navigate folder structures.

Instructions

List files and directories at the specified path on a remote WebDAV server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo/

Implementation Reference

  • MCP tool handler implementation for 'webdav_list_remote_directory'. Defines the tool schema, description, and execution logic which lists directory contents using WebDAVService.list() and returns formatted JSON.
    server.tool(
      "webdav_list_remote_directory",
      "List files and directories at the specified path on a remote WebDAV server",
      {
        path: z.string().optional().default("/"),
      },
      async ({ path }) => {
        try {
          const files = await webdavService.list(path);
    
          // Format response
          const formattedFiles = files.map((file) => ({
            name: file.basename,
            path: file.filename,
            type: file.type,
            size: file.size,
            lastModified: file.lastmod,
          }));
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify(formattedFiles, null, 2),
            }],
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error listing directory: ${(error as Error).message}`,
            }],
            isError: true,
          };
        }
      },
    );
  • WebDAVService.list() method, the core helper function called by the tool handler to retrieve directory contents from the remote WebDAV server using the webdav library's getDirectoryContents.
    async list(path: string = "/"): Promise<FileStat[]> {
      const fullPath = this.getFullPath(path);
      logger.debug(`Listing directory: ${fullPath}`);
    
      try {
        // In v5.x we need to handle the response differently
        const result = await this.client.getDirectoryContents(fullPath);
    
        // Convert the result to our FileStat interface
        const fileStats = Array.isArray(result)
          ? result.map((item) => this.convertToFileStat(item))
          : this.isResponseData(result) && Array.isArray(result.data)
          ? result.data.map((item) => this.convertToFileStat(item))
          : [];
    
        logger.debug(
          `Listed ${fileStats.length} items in directory: ${fullPath}`,
        );
        return fileStats;
      } catch (error) {
        logger.error(`Error listing directory ${fullPath}:`, error);
        throw new Error(`Failed to list directory: ${(error as Error).message}`);
      }
    }
  • MCP prompt registration for 'webdav_list_remote_directory', providing a user prompt template for listing directories.
      server.prompt(
        "webdav_list_remote_directory",
        {
          path: z.string().optional(),
        },
        (args) => {
          const pathToUse = args.path || "/";
    
          return {
            messages: [
              {
                role: "user",
                content: {
                  type: "text",
                  text:
                    `List all files and directories in the remote WebDAV directory "${pathToUse}".
    
    Please provide a well-formatted list showing:
    - File/directory names
    - Types (file or directory)
    - Sizes (for files)
    - Last modified dates (if available)
    
    This is for a remote WebDAV server, not a local filesystem.`,
                },
              },
            ],
          };
        },
      );
  • MCP resource registration for 'webdav_list_remote_directory', providing a resource template for directory listing via URI.
      server.resource(
        "webdav_list_remote_directory",
        new ResourceTemplate("webdav://{path}/list", {
          // The list property expects a proper response format
          list: async () => {
            return {
              resources: [
                {
                  uri: "webdav://",
                  name: "WebDAV Root",
                  description: "Access to WebDAV resources",
                },
              ],
            };
          },
        }),
        async (uri, { path }) => {
          try {
            const normalizedPath = path ? String(path) : "/";
            const files = await webdavService.list(normalizedPath);
    
            // Format the file listing for display
            const content = files.map((file) => {
              const type = file.type === "directory" ? "Directory" : "File";
              const size = file.type === "file"
                ? `Size: ${formatSize(file.size)}`
                : "";
              const lastMod = file.lastmod ? `Last Modified: ${file.lastmod}` : "";
    
              return `${type}: ${file.basename}
    ${size}
    ${lastMod}
    Path: ${file.filename}
    ${"-".repeat(40)}`;
            }).join("\n");
    
            return {
              contents: [{
                uri: uri.href,
                text: content ? content : "Empty directory",
              }],
            };
          } catch (error) {
            return {
              contents: [{
                uri: uri.href,
                text: `Error listing directory: ${(error as Error).message}`,
              }],
            };
          }
        },
      );
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action but doesn't disclose behavioral traits such as whether it's read-only (implied by 'List'), potential authentication needs, rate limits, error handling, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 action ('List files and directories') and includes essential context ('at the specified path on a remote WebDAV server'). There is no wasted text, making it appropriately sized and well-structured.

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

Completeness3/5

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

Given 1 parameter with no output schema and no annotations, the description is minimally complete for a simple listing tool. It covers the basic purpose but lacks details on usage context, behavioral aspects, and output, which are needed for full understanding. It's adequate but with clear gaps in guidance and transparency.

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. The description adds meaning by specifying that the parameter is a 'path' on the remote server, which clarifies beyond the schema's type and default. However, it doesn't provide details like path format constraints or examples, so it partially compensates for the low 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 verb ('List') and resource ('files and directories') with the scope ('at the specified path on a remote WebDAV server'). It distinguishes from some siblings like 'webdav_get_directory_tree' by focusing on a single path, but doesn't explicitly differentiate from 'webdav_list_directory_with_sizes' which suggests a similar function with additional details.

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?

No guidance is provided on when to use this tool versus alternatives like 'webdav_get_directory_tree' (which might list recursively) or 'webdav_list_directory_with_sizes' (which includes size information). The description implies usage for listing contents at a path but lacks explicit comparisons or exclusions.

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