webdav_create_remote_file
Create and save files on remote WebDAV servers by specifying paths and content; optionally overwrite existing files. Simplify remote file management with direct configuration.
Instructions
Create a new file on a remote WebDAV server at the specified path
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| overwrite | No | ||
| path | Yes |
Implementation Reference
- src/handlers/tool-handlers.ts:7-47 (handler)The core handler function for the 'webdav_create_remote_file' tool. Includes inline schema validation using Zod, existence check, overwrite handling, file writing via WebDAVService, and error handling with formatted responses.server.tool( 'webdav_create_remote_file', 'Create a new file on a remote WebDAV server at the specified path', { path: z.string().min(1, 'Path must not be empty'), content: z.string(), overwrite: z.boolean().optional().default(false) }, async ({ path, content, overwrite }) => { try { // Check if file exists and respect overwrite flag const exists = await webdavService.exists(path); if (exists && !overwrite) { return { content: [{ type: 'text', text: `Error: File already exists at ${path}. Use overwrite=true to replace it.` }], isError: true }; } await webdavService.writeFile(path, content); return { content: [{ type: 'text', text: `File created successfully at ${path}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error creating file: ${(error as Error).message}` }], isError: true }; } } );
- src/handlers/tool-handlers.ts:11-14 (schema)Input schema for the webdav_create_remote_file tool using Zod for validation: path (string, required), content (string), overwrite (boolean, optional, default false).path: z.string().min(1, 'Path must not be empty'), content: z.string(), overwrite: z.boolean().optional().default(false) },
- src/handlers/tool-handlers.ts:7-47 (registration)Registration of the 'webdav_create_remote_file' tool on the MCP server within setupToolHandlers.server.tool( 'webdav_create_remote_file', 'Create a new file on a remote WebDAV server at the specified path', { path: z.string().min(1, 'Path must not be empty'), content: z.string(), overwrite: z.boolean().optional().default(false) }, async ({ path, content, overwrite }) => { try { // Check if file exists and respect overwrite flag const exists = await webdavService.exists(path); if (exists && !overwrite) { return { content: [{ type: 'text', text: `Error: File already exists at ${path}. Use overwrite=true to replace it.` }], isError: true }; } await webdavService.writeFile(path, content); return { content: [{ type: 'text', text: `File created successfully at ${path}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error creating file: ${(error as Error).message}` }], isError: true }; } } );
- src/lib.ts:78-78 (registration)High-level registration call to setupToolHandlers during MCP server initialization, which registers the webdav_create_remote_file tool among others.setupToolHandlers(server, webdavService);
- src/services/webdav-service.ts:33-33 (helper)WebDAVService class providing the writeFile method used by the tool handler for creating/updating remote files.export class WebDAVService {