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.
39 lines • 1.25 kB
JavaScript
import { z } from "zod";
import { BaseToolHandler } from "./BaseToolHandler.js";
const CopyFileSchema = z.object({
fileId: z.string(),
name: z.string().optional(),
parentId: z.string().optional(),
});
export class CopyFileHandler extends BaseToolHandler {
async runTool(args, drive) {
const validArgs = CopyFileSchema.parse(args);
const file = await this.copyFile(validArgs, drive);
return {
content: [{
type: "text",
text: `File copied successfully: ${file.name} (ID: ${file.id})`,
}],
isError: false,
};
}
async copyFile(args, drive) {
try {
const copyMetadata = {};
if (args.name)
copyMetadata.name = args.name;
if (args.parentId)
copyMetadata.parents = [args.parentId];
const response = await drive.files.copy({
fileId: args.fileId,
resource: copyMetadata,
fields: 'id,name',
});
return response.data;
}
catch (error) {
throw this.handleGoogleApiError(error);
}
}
}
//# sourceMappingURL=CopyFileHandler.js.map