webdav_create_remote_directory
Create a new directory on a remote WebDAV server by specifying the path, enabling organized file storage and management.
Instructions
Create a new directory on a remote WebDAV server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/handlers/tool-handlers.ts:162-188 (registration)MCP server.tool registration for 'webdav_create_remote_directory', including description, input schema, and inline async handler function that executes the logic.server.tool( 'webdav_create_remote_directory', 'Create a new directory on a remote WebDAV server', { path: z.string().min(1, 'Path must not be empty') }, async ({ path }) => { try { await webdavService.createDirectory(path); return { content: [{ type: 'text', text: `Directory created successfully at ${path}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error creating directory: ${(error as Error).message}` }], isError: true }; } } );
- Zod input schema validation for the tool parameters.{ path: z.string().min(1, 'Path must not be empty') },
- src/handlers/tool-handlers.ts:168-187 (handler)Inline handler function that performs input destructuring, calls the service, handles errors, and formats MCP response.async ({ path }) => { try { await webdavService.createDirectory(path); return { content: [{ type: 'text', text: `Directory created successfully at ${path}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error creating directory: ${(error as Error).message}` }], isError: true }; } }
- Supporting WebDAVService method implementing directory creation using the underlying WebDAV client, with path normalization, logging, error handling, and result validation.async createDirectory(path: string): Promise<void> { const fullPath = this.getFullPath(path); logger.debug(`Creating directory: ${fullPath}`); try { // createDirectory in v5.x returns a boolean indicating success const result = await this.client.createDirectory(fullPath); // Check result based on type if (typeof result === 'boolean' && !result) { throw new Error("Failed to create directory: server returned failure status"); } else if (this.isResponseData(result) && result.status !== undefined && result.status !== 201 && result.status !== 204) { throw new Error(`Failed to create directory: server returned status ${result.status}`); } logger.debug(`Successfully created directory: ${fullPath}`); } catch (error) { logger.error(`Error creating directory ${fullPath}:`, error); throw new Error(`Failed to create directory: ${(error as Error).message}`); } }