Skip to main content
Glama

mcp-google-sheets

duplicate-file.action.ts2.33 kB
import { Property, createAction } from '@activepieces/pieces-framework'; import { google } from 'googleapis'; import { OAuth2Client } from 'googleapis-common'; import { googleDriveAuth } from '../../index'; import { common } from '../common'; export const duplicateFileAction = createAction({ displayName: 'Duplicate File', auth: googleDriveAuth, name: 'duplicate_file', description: 'Duplicate a file from Google Drive. Returns the new file ID.', props: { fileId: Property.ShortText({ displayName: 'File ID', description: 'The ID of the file to duplicate', required: true, }), name: Property.ShortText({ displayName: 'Name', description: 'The name of the new file', required: true, }), folderId: Property.ShortText({ displayName: 'Folder ID', description: 'The ID of the folder where the file will be duplicated', required: true, }), mimeType: Property.StaticDropdown({ displayName: 'Duplicate as', description: 'If left unselected the file will be duplicated as it is', required: false, options: { options: [ { label: 'Google Sheets', value: 'application/vnd.google-apps.spreadsheet', }, { label: 'Google Docs', value: 'application/vnd.google-apps.document', } ], }, }), include_team_drives: common.properties.include_team_drives, }, async run(context) { const authClient = new OAuth2Client(); authClient.setCredentials(context.auth); const fileId = context.propsValue.fileId; const nameForNewFile = context.propsValue.name; const parentFolderId = context.propsValue.folderId; const mimeType = context.propsValue.mimeType; const drive = google.drive({ version: 'v3', auth: authClient }); const requestBody: any = { name: nameForNewFile, parents: [parentFolderId], }; if (mimeType) { requestBody.mimeType = mimeType; } const response = await drive.files.copy({ fileId, auth: authClient, requestBody, supportsAllDrives: context.propsValue.include_team_drives, }); if (response.status !== 200) { throw new Error('Error duplicating file'); } return response.data; }, });

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/activepieces/activepieces'

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