Skip to main content
Glama
anyrxo
by anyrxo

write_file

Create or write text files directly to Proton Drive by specifying the file path and content using Proton Drive MCP server integration.

Instructions

Write or create a file in Proton Drive

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesText content to write to the file
pathYesFile path relative to Proton Drive root

Implementation Reference

  • The switch case handler that executes the write_file tool logic: extracts path and content arguments, validates the path, creates parent directories if necessary, writes the file using fs/promises.writeFile, returns a success text response, or throws an MCP error on failure.
    case 'write_file': { const writePath = validatePath(args?.path as string); const content = args?.content as string; try { // Create directory if needed await mkdir(dirname(writePath), { recursive: true }); // Write the file await writeFile(writePath, content, 'utf-8'); return { content: [ { type: 'text', text: `Successfully wrote file: ${getRelativePath(writePath)}`, }, ], }; } catch (error: any) { throw new McpError( ErrorCode.InternalError, `Cannot write file: ${error.message}` ); } }
  • src/index.ts:159-176 (registration)
    The tool registration object for 'write_file' returned by the ListTools handler, defining the tool's name, description, and input schema (JSON Schema object with required 'path' and 'content' string properties).
    { name: 'write_file', description: 'Write or create a file in Proton Drive', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File path relative to Proton Drive root' }, content: { type: 'string', description: 'Text content to write to the file' }, }, required: ['path', 'content'], }, },
  • Helper function used by write_file (and other tools) to validate and resolve relative paths to absolute paths within the Proton Drive root directory, preventing path traversal attacks.
    function validatePath(relativePath: string): string { // Handle empty path if (!relativePath) { return PROTON_DRIVE_PATH; } // Clean the path - remove leading slashes and normalize const cleaned = relativePath .split(/[/\\]+/) .filter(Boolean) .join(sep); const fullPath = resolve(PROTON_DRIVE_PATH, cleaned); // Security check - ensure we're still within Proton Drive if (!fullPath.startsWith(PROTON_DRIVE_PATH)) { throw new Error('Invalid path: Access denied outside Proton Drive'); } return fullPath; }
  • The JSON Schema defining the input parameters for the write_file tool: an object with string properties 'path' and 'content', both required.
    inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File path relative to Proton Drive root' }, content: { type: 'string', description: 'Text content to write to the file' }, }, required: ['path', 'content'], },

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/anyrxo/proton-drive-mcp'

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