Skip to main content
Glama
LaubPlusCo

WebDAV MCP Server

by LaubPlusCo

webdav_create_remote_file

Create new files on remote WebDAV servers by specifying file paths and content, with optional overwrite control for existing files.

Instructions

Create a new file on a remote WebDAV server at the specified path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
contentYes
overwriteNo

Implementation Reference

  • Primary handler implementation for the 'webdav_create_remote_file' tool, including input schema validation, existence check with overwrite option, delegation to WebDAVService.writeFile, success/error responses.
    '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 }; } } );
  • Core helper function WebDAVService.writeFile that resolves full path, logs operation, calls WebDAVClient.putFileContents to create/update the remote file, and handles response validation and errors.
    async writeFile(path: string, content: string | Buffer): Promise<void> { const fullPath = this.getFullPath(path); const contentLength = typeof content === 'string' ? content.length : content.length; logger.debug(`Writing file: ${fullPath}`, { contentLength }); try { // putFileContents in v5.x returns a boolean indicating success const result = await this.client.putFileContents(fullPath, content); // Check result based on type if (typeof result === 'boolean' && !result) { throw new Error("Failed to write file: server returned failure status"); } else if (this.isResponseData(result) && result.status !== undefined && result.status !== 201 && result.status !== 204) { throw new Error(`Failed to write file: server returned status ${result.status}`); } logger.debug(`Successfully wrote file: ${fullPath}`); } catch (error) { logger.error(`Error writing to file ${fullPath}:`, error); throw new Error(`Failed to write file: ${(error as Error).message}`); } }
  • src/lib.ts:75-80 (registration)
    Top-level server initialization where setupToolHandlers is invoked to register all tools, including webdav_create_remote_file.
    logger.debug('Setting up MCP handlers'); setupResourceHandlers(server, webdavService); setupToolHandlers(server, webdavService); setupPromptHandlers(server);

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/LaubPlusCo/mcp-webdav-server'

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