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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_my_files_and_folders"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | The specific folder path to list. For example, 'Documents/Work'. If empty, lists files and folders in the main (root) directory. |
Implementation Reference
- index.js:242-270 (handler)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 }; } } - index.js:238-240 (schema)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 }; } } );