Skip to main content
Glama
anyrxo

Proton Drive MCP

by anyrxo

read_file

Retrieve and display text file contents stored in Proton Drive by specifying the file path to access documents directly from your secure cloud storage.

Instructions

Read a text file from Proton Drive

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path relative to Proton Drive root

Implementation Reference

  • The main handler logic for the 'read_file' tool. It validates the input path, checks if the target is a file (not directory), reads the file content using Node.js fs/promises.readFile, and returns it as MCP text content block. Errors are handled with McpError.
    case 'read_file': {
      const readPath = validatePath(args?.path as string);
      
      try {
        // Check if it's a file
        const stats = await stat(readPath);
        if (stats.isDirectory()) {
          throw new Error('Cannot read a directory');
        }
        
        // Read the file
        const content = await readFile(readPath, 'utf-8');
        return {
          content: [
            {
              type: 'text',
              text: content,
            },
          ],
        };
      } catch (error: any) {
        throw new McpError(
          ErrorCode.InternalError,
          `Cannot read file: ${error.message}`
        );
      }
    }
  • Input schema definition for the 'read_file' tool, specifying an object with a required 'path' string property.
    inputSchema: {
      type: 'object',
      properties: {
        path: { 
          type: 'string', 
          description: 'File path relative to Proton Drive root' 
        },
      },
      required: ['path'],
    },
  • src/index.ts:145-158 (registration)
    Registration of the 'read_file' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'read_file',
      description: 'Read a text file from Proton Drive',
      inputSchema: {
        type: 'object',
        properties: {
          path: { 
            type: 'string', 
            description: 'File path relative to Proton Drive root' 
          },
        },
        required: ['path'],
      },
    },
  • Helper function used by read_file (and other tools) to validate and resolve relative paths to absolute paths within the Proton Drive root, 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;
    }

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