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.43 kB
JavaScript
import { z } from "zod";
import { BaseToolHandler } from "./BaseToolHandler.js";
const ListSharedDrivesSchema = z.object({
pageSize: z.number().default(20),
pageToken: z.string().optional(),
});
export class ListSharedDrivesHandler extends BaseToolHandler {
async runTool(args, drive) {
const validArgs = ListSharedDrivesSchema.parse(args);
const drives = await this.listSharedDrives(validArgs, drive);
return {
content: [{
type: "text",
text: this.formatSharedDrives(drives),
}],
isError: false,
};
}
async listSharedDrives(args, drive) {
try {
const response = await drive.drives.list({
pageSize: args.pageSize,
pageToken: args.pageToken,
fields: 'drives(id,name,createdTime,capabilities),nextPageToken',
});
return response.data.drives || [];
}
catch (error) {
throw this.handleGoogleApiError(error);
}
}
formatSharedDrives(drives) {
if (drives.length === 0) {
return "No shared drives found.";
}
return drives.map((drive, index) => `${index + 1}. **${drive.name}** (ID: \`${drive.id}\`)
- Created: ${new Date(drive.createdTime).toLocaleString()}`).join('\n\n');
}
}
//# sourceMappingURL=ListSharedDrivesHandler.js.map