mcp-gdrive-enhanced-markov
Version:
MCP server for Google Drive and Sheets with write capabilities, AI-powered PDF analysis, SQLite document indexing, and advanced directory exploration tools
57 lines (56 loc) • 1.73 kB
JavaScript
import { google } from "googleapis";
export const schema = {
name: "gdrive_move_file",
description: "Move a file or folder to a different parent folder in Google Drive",
inputSchema: {
type: "object",
properties: {
fileId: {
type: "string",
description: "ID of the file or folder to move"
},
newParentId: {
type: "string",
description: "ID of the new parent folder"
}
},
required: ["fileId", "newParentId"]
}
};
export async function moveFile(args) {
try {
const drive = google.drive({ version: "v3" });
// First, get the current parents
const file = await drive.files.get({
fileId: args.fileId,
fields: "id,name,parents"
});
// Remove from current parents and add to new parent
const previousParents = file.data.parents ? file.data.parents.join(',') : '';
const response = await drive.files.update({
fileId: args.fileId,
addParents: args.newParentId,
removeParents: previousParents,
fields: "id,name,parents"
});
return {
content: [{
type: "text",
text: `File moved successfully:
- Name: ${response.data.name}
- ID: ${response.data.id}
- New Parent: ${args.newParentId}`
}],
isError: false
};
}
catch (error) {
return {
content: [{
type: "text",
text: `Error moving file: ${error.message || error}`
}],
isError: true
};
}
}