Skip to main content
Glama
anyrxo
by anyrxo

read_file

Retrieve and read text files stored in Proton Drive by specifying the file path. Enables access to file content for integration with workflows or data processing systems.

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 using validatePath helper, checks if the path is a file (not directory), reads the file content using Node.js fs/promises readFile, and returns the content wrapped in the MCP response format. Errors are caught and thrown as 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}` ); } }
  • src/index.ts:145-158 (registration)
    Registration of the 'read_file' tool in the ListToolsRequestSchema handler. Includes the tool name, description, and input schema specifying the required 'path' parameter.
    { 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 the read_file handler (and others) to validate and resolve the relative path to an absolute path 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; }

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