Skip to main content
Glama

read_file

Access file contents from designated directories to support revenue tracking and business management workflows in Google Workspace.

Instructions

Read contents of a file. Only works in allowed directories: revenue-engine-mcp, apps-script folders

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFull file path (e.g., C:\Users\Node1\revenue-engine-mcp\index.js)

Implementation Reference

  • The handler for the 'read_file' tool. Validates the input path using isPathAllowed, checks if the file exists, reads the file content synchronously using fs.readFileSync, and returns a structured response with success status, path, content, and size.
    case "read_file": {
      const { path } = args;
      
      if (!isPathAllowed(path)) {
        throw new Error(`Access denied: Path not in allowed directories`);
      }
    
      if (!fs.existsSync(path)) {
        throw new Error(`File not found: ${path}`);
      }
    
      const content = fs.readFileSync(path, 'utf8');
      result = {
        success: true,
        path: path,
        content: content,
        size: content.length
      };
      break;
    }
  • The input schema definition for the 'read_file' tool, specifying the required 'path' parameter as a string, listed in the tools response for ListToolsRequest.
    {
      name: "read_file",
      description: "Read contents of a file. Only works in allowed directories: revenue-engine-mcp, apps-script folders",
      inputSchema: {
        type: "object",
        properties: {
          path: { 
            type: "string", 
            description: "Full file path (e.g., C:\\Users\\Node1\\revenue-engine-mcp\\index.js)" 
          }
        },
        required: ["path"]
      }
    },
  • Helper function used by read_file (and other FS tools) to check if the provided path is within allowed directories, preventing access to unauthorized files.
    function isPathAllowed(filePath) {
      const normalized = filePath.replace(/\//g, '\\');
      return ALLOWED_PATHS.some(allowedPath => 
        normalized.startsWith(allowedPath)
      );
    }

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/PromptishOperations/mcpSpec'

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