UNPKG

mcp-google-drive

Version:

Advanced MCP server for Google Drive integration with full CRUD operations, file management, and sharing capabilities. Supports both OAuth2 and Service Account authentication.

37 lines 1.37 kB
import { z } from "zod"; import { BaseToolHandler } from "./BaseToolHandler.js"; const GetFilePermissionsSchema = z.object({ fileId: z.string(), }); export class GetFilePermissionsHandler extends BaseToolHandler { async runTool(args, drive) { const validArgs = GetFilePermissionsSchema.parse(args); const permissions = await this.getFilePermissions(validArgs, drive); return { content: [{ type: "text", text: this.formatPermissions(permissions), }], isError: false, }; } async getFilePermissions(args, drive) { try { const response = await drive.permissions.list({ fileId: args.fileId, fields: 'permissions(id,emailAddress,domain,role,type,displayName)', }); return response.data.permissions || []; } catch (error) { throw this.handleGoogleApiError(error); } } formatPermissions(permissions) { if (permissions.length === 0) { return "No permissions found for this file."; } return permissions.map(perm => `- **${perm.displayName || perm.emailAddress || perm.domain || 'Anyone'}**: ${perm.role} (${perm.type})`).join('\n'); } } //# sourceMappingURL=GetFilePermissionsHandler.js.map