Skip to main content
Glama

list_my_files_and_folders

List files and folders in a specified directory or root path using the DAV MCP Server. Ideal for organizing and accessing Fastmail or iCloud WebDAV storage efficiently.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoThe specific folder path to list. For example, 'Documents/Work'. If empty, lists files and folders in the main (root) directory.

Implementation Reference

  • The handler function for the list_my_files_and_folders tool. It constructs a collection URL based on the optional path input, logs into the WebDAV client, fetches the objects (files/folders) using webDavClient.fetchObjects, and returns them as JSON or an error message.
    async ({ path }) => { try { await webDavClient.login(); let collectionUrl = webDavClient.serverUrl; // Base server URL from client if (path && path !== '/') { // Ensure no double slashes and correct joining const base = collectionUrl.endsWith('/') ? collectionUrl.slice(0, -1) : collectionUrl; const relativePath = path.startsWith('/') ? path.substring(1) : path; collectionUrl = `${base}/${relativePath}`; } const objects = await webDavClient.fetchObjects({ collection: collectionUrl }); return { content: [{ type: "text", text: JSON.stringify(objects, null, 2) }] }; } catch (error) { console.error(`Error in list_my_files_and_folders_from_${DAV_PROVIDER}:`, error); return { content: [{ type: "text", text: `Error listing WebDAV collection: ${JSON.stringify(error.message || error)}` }], isError: true }; } }
  • The input schema for the tool, defining an optional 'path' string parameter to specify the folder to list.
    inputSchema: { path: z.string().optional().describe("The specific folder path to list. For example, 'Documents/Work'. If empty, lists files and folders in the main (root) directory."), },
  • index.js:235-271 (registration)
    The server.tool() registration call for the tool named `list_my_files_and_folders_from_${DAV_PROVIDER}` (e.g., list_my_files_and_folders_from_fastmail), which includes the dynamic name, description, input schema, and handler reference. This is conditionally registered only if webDavClient is initialized (for providers like fastmail).
    `list_my_files_and_folders_from_${DAV_PROVIDER}`, { description: `Lists files and folders from your ${DAV_PROVIDER} WebDAV storage. You can optionally provide a \`path\` to a specific folder. If no path is provided, it lists items from the root directory. This is only available for providers that support WebDAV.`, inputSchema: { path: z.string().optional().describe("The specific folder path to list. For example, 'Documents/Work'. If empty, lists files and folders in the main (root) directory."), }, }, async ({ path }) => { try { await webDavClient.login(); let collectionUrl = webDavClient.serverUrl; // Base server URL from client if (path && path !== '/') { // Ensure no double slashes and correct joining const base = collectionUrl.endsWith('/') ? collectionUrl.slice(0, -1) : collectionUrl; const relativePath = path.startsWith('/') ? path.substring(1) : path; collectionUrl = `${base}/${relativePath}`; } const objects = await webDavClient.fetchObjects({ collection: collectionUrl }); return { content: [{ type: "text", text: JSON.stringify(objects, null, 2) }] }; } catch (error) { console.error(`Error in list_my_files_and_folders_from_${DAV_PROVIDER}:`, error); return { content: [{ type: "text", text: `Error listing WebDAV collection: ${JSON.stringify(error.message || error)}` }], isError: true }; } } );

Other Tools

Related 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/jahfer/dav-mcp-server'

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