Skip to main content
Glama
anyrxo

Proton Drive MCP

by anyrxo

list_files

Browse files and folders stored in Proton Drive by specifying a directory path to view its contents.

Instructions

List files and folders in Proton Drive

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoPath relative to Proton Drive root (e.g., "Documents" or "Projects/2024")

Implementation Reference

  • The main handler for the 'list_files' tool. It validates the path, reads directory entries, filters out hidden files, fetches stats, builds file objects with relative paths, sorts (folders first), and returns JSON.
    case 'list_files': {
      const listPath = validatePath(args?.path as string || '');
      
      try {
        const entries = await readdir(listPath, { withFileTypes: true });
        const files = await Promise.all(
          entries
            .filter(entry => !entry.name.startsWith('.'))
            .map(async (entry) => {
              const fullPath = join(listPath, entry.name);
              const relativePath = getRelativePath(fullPath);
              const stats = await stat(fullPath);
              
              return {
                name: entry.name,
                path: relativePath,
                type: entry.isDirectory() ? 'folder' : 'file',
                size: stats.size,
                modified: stats.mtime.toISOString(),
              };
            })
        );
        
        // Sort folders first, then files
        files.sort((a, b) => {
          if (a.type === b.type) {
            return a.name.localeCompare(b.name);
          }
          return a.type === 'folder' ? -1 : 1;
        });
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(files, null, 2),
            },
          ],
        };
      } catch (error: any) {
        throw new McpError(
          ErrorCode.InternalError,
          `Cannot list directory: ${error.message}`
        );
      }
    }
  • Input schema for list_files tool defining an optional 'path' property as string.
    inputSchema: {
      type: 'object',
      properties: {
        path: { 
          type: 'string', 
          description: 'Path relative to Proton Drive root (e.g., "Documents" or "Projects/2024")' 
        },
      },
    },
  • src/index.ts:132-144 (registration)
    Registration of the 'list_files' tool in the listTools handler, providing name, description, and schema.
    {
      name: 'list_files',
      description: 'List files and folders in Proton Drive',
      inputSchema: {
        type: 'object',
        properties: {
          path: { 
            type: 'string', 
            description: 'Path relative to Proton Drive root (e.g., "Documents" or "Projects/2024")' 
          },
        },
      },
    },
  • validatePath helper used by list_files to secure and resolve relative paths to absolute within Proton Drive.
    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;
    }
  • getRelativePath helper used by list_files to compute display-friendly relative paths.
    function getRelativePath(fullPath: string): string {
      if (fullPath === PROTON_DRIVE_PATH) {
        return '/';
      }
      return fullPath.replace(PROTON_DRIVE_PATH, '').replace(/^[/\\]/, '') || '/';
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other 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