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.

40 lines 1.27 kB
import { z } from "zod"; import { BaseToolHandler } from "./BaseToolHandler.js"; const ShareFileSchema = z.object({ fileId: z.string(), email: z.string(), role: z.enum(["reader", "writer", "commenter", "owner"]), message: z.string().optional(), }); export class ShareFileHandler extends BaseToolHandler { async runTool(args, drive) { const validArgs = ShareFileSchema.parse(args); await this.shareFile(validArgs, drive); return { content: [{ type: "text", text: `File shared successfully with ${validArgs.email} (${validArgs.role})`, }], isError: false, }; } async shareFile(args, drive) { try { const permission = { type: 'user', role: args.role, emailAddress: args.email, }; await drive.permissions.create({ fileId: args.fileId, resource: permission, emailMessage: args.message, sendNotificationEmail: true, }); } catch (error) { throw this.handleGoogleApiError(error); } } } //# sourceMappingURL=ShareFileHandler.js.map